import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Main{

	public void calculate(){
		Scanner input = new Scanner(System.in);

		//?????????????????¶??°???????????????
		long numSellings = Long.parseLong(input.nextLine());

		//?????????????????¶??°???0??????????????§????????????
		while(numSellings != 0){

			//??????????????????????????????????????¬?????????????????????????????????
			ArrayList<Long> staffs = new ArrayList<Long>();
			//????????¨????£??????????????????????
			HashMap<Long,Long> staffProceedMap = new HashMap<Long,Long>();

			//??¶??°?????§?¨?????????????
			for(int i = 0; i < numSellings; i++){
				//??????????????????????????????????????¨??????????£?????£??????????????¨??????????
				String[] lines = input.nextLine().split(" ");
				long staffNo = Long.parseLong(lines[0]);
				long price   = Long.parseLong(lines[1]) * Long.parseLong(lines[2]);

				//????????????????????????????£??????±?????\?????????
				if(staffProceedMap.containsKey(staffNo)){
					//2?????\??????????£?????????£????????????value????¶???????????????¢?????????
					staffProceedMap.put(staffNo,price + staffProceedMap.get(staffNo));
				} else {
					//1????????????????£?????????£?????????????????????????????????????????±???????????????
					staffs.add(staffNo);
					staffProceedMap.put(staffNo,price);
				}
			}

			//??¨???????????????????????§???????????¨??????????????¨??????
			boolean success = false;

			//???????????????????????§????????????????£?????????????????????????
			for(long staff : staffs){
				if(staffProceedMap.get(staff) >= 1000000){
					System.out.println(staff);
					success = true;
				}
			}

			if(!success){
				System.out.println("NA");
			}
			numSellings = Long.parseLong(input.nextLine());
		}
		input.close();
	}

	public static void main (String[] args) throws java.lang.Exception{

		Main saleResult = new Main();
		saleResult.calculate();
	}
}