数塔
import java.util.*;
class Main{
public static void main(String args[])
{
Scanner scanner=new Scanner(System.in);
int C=scanner.nextInt();
while(C--!=0)
{
int N=scanner.nextInt();
int [][]tower=new int[N][N];
for(int i=0;i<N;i++)
for(int j=0;j<=i;j++)
tower[i][j]=scanner.nextInt();
for(int i=N-2;i>=0;i--)
for(int j=0;j<=i;j++)
tower[i][j]+=Math.max(tower[i+1][j],tower[i+1][j+1]);
System.out.println(tower[0][0]);
}
}
}