#include <iostream>
#include <set>
using namespace std;main(){int n,m;while(cin>>n&&n){set<long>T;m=1;while(n--){long U,p,s;cin>>U>>p>>s;if(T.find(U)==T.end()&&p*s>=1000000)m=0,cout<<U<<'\n',T.insert(U);}if(m)cout<<"NA\n";}}