#include <iostream>

using namespace std;

/* SANITY CHECK: assertion macro for verifying input data and internal state */
#define ASSERT(e) { if(!(e)) { cerr << #e << endl; throw; } }

/* Main body of program */
void process(void)
{
    int data_num, data_idx;

    /* Read how many data sets to process */
    cin >> data_num;
    
    /* Process each data set separately */
    for(data_idx = 0; data_idx < data_num; data_idx++) {
        int image_idx, image_num;
        int total = 0;

        cin >> image_num;
        ASSERT(1 <= image_num && image_num <= 10);
        
        /* Compute size (in sq.in) of a complete pattern */
        for(image_idx = 0; image_idx < image_num; image_idx++) {
            int sqin, ratio;
            
            cin >> sqin >> ratio;
            ASSERT(1 <= sqin && sqin <= 1000);
            ASSERT(1 <= ratio && ratio <= 100);
            
            total += sqin * ratio;
        }
        
        /*
         * There are 36*36=1296 inches in one square yard. Print out how many
         * complete image patterns will fit within 1, 2, and 3 square yards.
         */
        cout << 1296 / total << " ";
        cout << 1296 * 2 / total << " ";
        cout << 1296 * 3 / total << endl;
    }
}

/* Run program and print out any exceptions that occur */
int main(void)
{
    /* Throw exceptions on failed data extraction in >> operator */
    cin.exceptions(ios::failbit);
    
    /* Run main body of code */
    try {
        process();
    }
    
    /* Catch unexpected EOF or bad input data */
    catch(ios::failure const &e) {
        cerr << "Unexpected EOF or data type mismatch on input" << endl;
    }

    return 0;
}