module AOJ_Volume0100;

import std.stdio,std.string,std.conv,std.array;

int main()
{
	while(true)
	{
		int n = readln.chomp.to!int;
		if(n == 0) break;

		ulong v[4001];
		foreach(i;0..4001) v[i] = 0;
		int ans[];
		int num;
		ulong k,m;
		foreach(i;0..n)
		{
			string[] s = readln.chomp.split(" ");
			num = s[0].to!int;
			k = s[1].to!int;
			m = s[2].to!int;

			bool flag = true;

			foreach(j;0..ans.length)
			{
				if(ans[j] == num) flag = false;
			}

			if(flag)
			{
				v[num] += k*m;
				if(v[num] >= 1000000)
				{
					ans ~= num;
				}
			}
		}

		if(ans.length == 0)
		{
			writeln("NA");
		}
		else
		{
			foreach(i;0..ans.length)
			{
				ans[i].writeln;
			}
		}
	}
	return 0;
}