using System;

namespace V1_SaleReasult
{
    class Program
    {
        static void Main(string[] args)
        {
                int DataNum = int.Parse(Console.ReadLine());
                int[,] ID = new int[4000, 2];
                if (DataNum != 0) { 

                string[] EmployeesData = new string[2];
                int j = 0;
                for (int i = 0; i < DataNum; i++)
                {
                    int sales;
                    EmployeesData = Console.ReadLine().Split(' ');
                    sales = int.Parse(EmployeesData[0]) * int.Parse(EmployeesData[1]);
                    if (sales >= 1000000)
                    {
                        ID[j, 0] = int.Parse(EmployeesData[0]);
                        ID[j, 1] = sales;
                        j++;
                    }
                }

                if (j == 0)
                    Console.WriteLine("NA");
                if (j != 0)
                {
                    for (int s = 0; s < j; j++)
                    {
                        for (int k = 0; k <= 1; k++)
                        {
                            Console.WriteLine(ID[s, k]);
                        }
                    }
                }

            }
        }
    }
}