#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>
//1000
#include <ctype.h>
using namespace std;long a,z,x,y,b[4001];bool s,p[4001];
int main(){
	while(cin>>a){
		if(a==0){break;}
	for(int aa=1;aa<=4000;aa++){
	b[aa]=0;p[aa]=false;}
	s=false;
	for(int i=0;i<a;i++){cin>>x>>y>>z;
	b[x]+=y*z;if(b[x]>=1000000&&p[x]==false){cout<<x<<endl;s=true;p[x]=true;}}
	if(s==false){cout<<"NA"<<endl;}}
return 0;}
