Problem: There is data on sales of your company. Your task is to write a program which identifies good workers.

The program should read a list of data where each item includes the employee ID i, the amount of sales q and the corresponding unit price p. Then, the program should print IDs of employees whose total sales proceeds (i.e. sum of p × q) is greater than or equal to 1,000,000 in the order of inputting. If there is no such employees, the program should print "NA". You can suppose that n < 4000, and each employee has an unique ID. The unit price p is less than or equal to 1,000,000 and the amount of sales q is less than or equal to 100,000.



Input

The input consists of several datasets. The input ends with a line including a single 0. Each dataset consists of:


n (the number of data in the list)
i p q
i p q
:
:
i p q


Output

For each dataset, print a list of employee IDs or a text "NA"

Example

Input

4
1001 2000 520
1002 1800 450
1003 1600 625
1001 200 1220
2
1001 100 3
1005 1000 100
2
2013 5000 100
2013 5000 100
0


Output

1001
1003
NA
2013

Solution (in JAVA):

Solution:

import java.io.*;
import java.util.*;


// æ­Ôá¤Æ±ëB
// âè¶É¢ÄÈ­ÄàâèZbgÍ¡Åæªª0ÅI¹Å éB
// âèZbgÌJèÔµÉú»Rê

// 2011/10/18

//@0100 Sale Result
public class Main {

	
	// C return falseÅ¨µÜ¢
	boolean main() throws IOException {

		int N = readIntArray()[0];
		if (N == 0)
			return false; /* ¨µÜ¢ */

		List<Integer> banList = new ArrayList<Integer>(); // ÐõÔXg 
		List<Long> sumList = new ArrayList<Long>(); // èã°v 
		
		for(int i = 0; i < N; i++) {
			int[] ir = readIntArray();
			int ban = ir[0];
			long tan = ir[1];
			long su = ir[2];
			
			int idx = banList.indexOf(ban);
			if (idx < 0) {
				banList.add(ban);
				sumList.add(tan * su);
			}
			else {
				sumList.set(idx, sumList.get(idx) + tan * su);
			}
		}

		int cnt = 0;
		for(int i = 0; i < banList.size(); i++) {
			if (sumList.get(i) >= 1000000L) {
				System.out.printf("%d\n", banList.get(i));
				cnt++;
			}
		}

		if (cnt == 0)
			System.out.printf("NA\n");
		
		return true; /* ³íI¹ Ö */
	}
	

//	private final static boolean DEBUG = true;  // debug
	private final static boolean DEBUG = false; // release

	public static void main(String[] args) throws IOException {

		if (DEBUG) {
			log = System.out;
			
			String inputStr = "4\n0 0 10 0 10 10 0 10\n10\n12\n0 5\n9 5\n0\n"; // 108.0
//			String inputStr = "4\n0 0 10 0 10 10 0 10\n10\n12\n0 0\n9 1\n0\n"; // 96.63324958071081
//			String inputStr = "4\n0 0 10 0 10 10 0 10\n10\n12\n0 1\n9 1\n0\n"; // 103.2664991614216
//			String inputStr = "8\n2 0 4 0 6 2 6 4 4 6 2 6 0 4 0 2\n10\n12\n3 0\n3 5\n0\n"; // 60.0

			reader = new BufferedReader(new StringReader(inputStr)); 

		}
		else {
			log = new PrintStream(new OutputStream() { public void write(int b) {} } ); // «ÌÄ
			reader = new BufferedReader(new InputStreamReader(System.in)); // R\[©ç
		}

		for(int loop = 0;; loop++) {
			boolean b = new Main().main();
			if (!b)
				break;
		}		
		
		reader.close();
	}

	
	static PrintStream log;
	static BufferedReader reader;
	

	// WüÍæè@1sªÌXy[XæØèÌ®lðÇÞ
	private int[] readIntArray() throws IOException {
		
		String s = reader.readLine();
		String[] sp = s.split(" ");
		int[] a = new int[sp.length];
		for(int i = 0; i < sp.length; i++) {
			a[i] = Integer.parseInt(sp[i]);
		}
		return a;
	}
		
}