/*
 Jason Kincl
 Textiles
*/

import java.util.Scanner;

public class textiles {

	public static final int ONESQYRD = 1296;
	public static final int TWOSQYRD = 2592;
	public static final int THREESQYRD = 3888;
	
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		
		int dataSets = in.nextInt();
		// for each data set
		for (int i = 0; i < dataSets; i++)
		{
			int images = in.nextInt();
			// for each image
			int fullSet = 0;
			for (int c = 0; c < images; c++)
			{
				int sqInchImg = in.nextInt();
				int count = in.nextInt();
				
				fullSet += sqInchImg * count;
			}
			
			System.out.printf("%d %d %d%n",(ONESQYRD / fullSet), (TWOSQYRD / fullSet), (THREESQYRD / fullSet));
		}
		
	}
	
}