// Arup Guha
// 1/26/2019
// Alternate Solution to 2019 Proposed Mercer Problem: Tweet Writer

import java.util.*;

public class tweet_arup {
	
	public static void main(String[] args) {
		
		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();
		
		// Process each case.
		for (int loop=0; loop<numCases; loop++) {
			
			// Get the number of days.
			int numDays = stdin.nextInt();
			int mikeCnt = 0;
			
			// Go through each day.
			for (int i=0; i<numDays; i++) {
				
				// Read in all three tweet counts for the day.
				int[] tweets = new int[3];
				for (int j=0; j<3; j++) 
					tweets[j] = stdin.nextInt();
				
				// If you read the text, the rotation order is 0, 2, 1
				// Mathematically, what I have below achieves that.
				mikeCnt += tweets[(3-i%3)%3];
			}
			
			// Ta da!
			System.out.println(mikeCnt);
		}
	}
}
