#!/usr/bin/env python

# Textiles
# Phil Bordelon

import os
import sys

DEBUG = os.getenv("DEBUG", False)

# How many inches are in a yard?

# How many square inches are in a square yard?

if "__main__" == __name__:

   dataset_count = int(sys.stdin.readline())
   for dataset_loop in range(dataset_count):

      # Get the number of images for this particular piece of fabric.
      image_count = int(sys.stdin.readline())

      # Start with the full set taking up zero square inches.
      full_set_size = 0

      # For each image ...
      for image_loop in range(image_count):

         # Read the size and count.
         image_size, image_count = [int(x) for x in

         # Increase the full set size by the size of the image times
         # its count.
         full_set_size += image_size * image_count

      # Calculate how many fit on one, two, and three square yards of fabric.
      # Note that you can't just calculate the value for one yard and then
      # multiply it; this is as close as this problem comes to a gotcha.
      one_yard = int(SQ_IN_IN_SQ_YARD / full_set_size)
      two_yards = int(2 * SQ_IN_IN_SQ_YARD / full_set_size)
      three_yards = int(3 * SQ_IN_IN_SQ_YARD / full_set_size)
      print("%d %d %d" % (one_yard, two_yards, three_yards))