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

public class Main {
	private static Scanner sc;

	public static void main(String[] args) throws Exception {
		sc = new Scanner(System.in);

		/**
		 * ???????????????????????????dateQuantity???????????????????????§??????????¶???????
		 */
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
		int dateQuantity = sc.nextInt(); // ??????????????????????????°???????????????
		while (dateQuantity != 0) {
			for (int i = 0; i < dateQuantity; i++) {
				int memberNum = sc.nextInt();
				int sales = sc.nextInt() * sc.nextInt();

				map = addsToMap(memberNum, sales, map); // ??????????????¨?£????????¨????
			}
			handlesMap(map); // ???????????????????????????1,000,000???????¶????????£????????????????????????????
			map.clear(); // ??????????????¨?¶????
			dateQuantity = sc.nextInt(); // ??????????????????????????°???????????????
		}
	}

	/**
	 * ???????????????????????????1,000,000???????¶????????£????????????????????????????
	 * @param map?????????????????¨?£??????????????????\?????????
	 */
	private static void handlesMap(HashMap<Integer, Integer> map) {
		boolean isQualityStaff = false;
		for (Integer key : map.keySet()) {
			int sales = map.get(key);
			if (sales >= 1000000) {
				System.out.println(key); // ?????????????????????
				isQualityStaff = true;
			}
		}
		if (!isQualityStaff) // ??????1,000,000???????¶????????£??????????????????????????????°
			System.out.println("NA");
	}

	/**
	 * ??????????????¨?£????????¨????
	 * @param memberNum???????????????
	 * @param sales????£????
	 * @param map???????¨?????????????????????\?????????
	 * @return???????????????map?????????
	 */
	private static HashMap<Integer, Integer> addsToMap(int memberNum, int sales, HashMap<Integer, Integer> map) {
		if (map.containsKey(memberNum)) {
			int tmpVal = map.get(memberNum);
			sales += tmpVal;
		}
		map.put(memberNum, sales);
		return map;
	}
}