using System;
using System.Collections;

public class p0100
{
	p0100 ()
	{
		string str;
		string[] st;
		int n, p;
		bool f;
		bool[] f2 = new bool[4001];
		
		while ((str=Console.ReadLine())!=null && str != "0") {
			n = int.Parse (str);
			f = true;
			for (int i = 0; i < 4001; ++i)
				f2 [i] = true;
			
			while(0 < n--){
				st = (Console.ReadLine()).Split(' ');
				p = int.Parse(st[0]);
				if(decimal.Parse(st[1])*decimal.Parse(st[2]) >= 1000000 && f2[p]){
					f = f2[p] = false;
					Console.WriteLine(st[0]);
				}
			}
			if(f) Console.WriteLine("NA");
		}
	}
	
	public static int Main(string[] args){
		new p0100();
		return 0;
	}
}