import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);String x;for(long t,v;(t=s.nextInt())>0;System.out.print(x.isEmpty()?"NA\n":x)){List<String>l=new ArrayList<String>();Map<String,Long> m=new HashMap<String,Long>();for(;t-->0;){if(!l.contains(x=s.next())){l.add(x);v=0;}else v=m.get(x);m.put(x,s.nextLong()*s.nextLong()+v);}x="";for(String y:l)if(m.get(y)>999999)x+=y+"\n";}}}