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

Difficulty: UNKNOWN_DIFFICULTY

Solutions:
while True:
	n = int(input())
	if n == 0:
		break
	personel = {}
	for _ in range(n):
		(e, p, q) = input().split()
		if e in personel.keys():
			personel[e] += int(p) * int(q)
		else:
			personel[e] = int(p) * int(q)
	result = []
	for (key, val) in personel.items():
		if val >= 1000000:
			result.append(key)
	if not result:
		print('NA')
	else:
		print('\n'.join(result))


while 1:
	n = int(input())
	if not n:
		break
	f = 1
	L = {}
	for (a, b, c) in [input().split() for i in range(n)]:
		if a in L:
			if L[a] >= 1000000.0:
				continue
			L[a] += int(b) * int(c)
		else:
			L[a] = int(b) * int(c)
		if L[a] >= 1000000.0:
			print(a)
			f = 0
	if f:
		print('NA')


dataCount = int(input())
while dataCount > 0:
	employeeSalesList = []
	for _ in range(dataCount):
		dataList = input().split(' ')
		(employeeId, price) = (dataList[0], int(dataList[1]) * int(dataList[2]))
		for data in employeeSalesList:
			if data[0] == employeeId:
				data[1] += price
				continue
		employeeSalesList.append([employeeId, price])
	answerList = [data[0] for data in employeeSalesList if data[1] >= 1000000]
	if answerList:
		print('\n'.join(map(str, answerList)))
	else:
		print('NA')
	dataCount = int(input())


def parse(i):
	l = input().strip().split()
	return ((i, l[0]), int(l[1]) * int(l[2]))
n = int(input())
while n:
	(ss, d) = ([parse(_) for _ in range(n)], {})
	for s in ss:
		k = s[0][1]
		d[k] = (d[k][0], d[k][1] + s[1]) if k in d else s
	d = [v[0] for v in d.values() if v[1] >= 1000000]
	if d:
		print('\n'.join((k[1] for k in sorted(d))))
	else:
		print('NA')
	n = int(input())


from sys import stdin
for line in stdin:
	if int(line) == 0:
		break
	isEmpty = True
	record = {}
	for _ in range(int(line)):
		employee = input().split(' ')
		total = int(employee[1]) * int(employee[2])
		if total >= 1000000:
			print(employee[0])
			isEmpty = False
		else:
			e_t = record.get(employee[0])
			if e_t:
				e_t = record.get(employee[0]) + total
				if e_t >= 1000000:
					print(employee[0])
					isEmpty = False
				else:
					record[employee[0]] = e_t
			else:
				record[employee[0]] = total
	record.clear()
	if isEmpty:
		print('NA')


def searchEmployeeSales(employeeId):
	for data in employeeSalesList:
		if data[0] == employeeId:
			return data
	newData = [employeeId, 0]
	employeeSalesList.append(newData)
	return newData
dataCount = int(input())
while dataCount > 0:
	employeeSalesList = []
	for _ in range(dataCount):
		dataList = input().split(' ')
		(employeeId, price) = (dataList[0], int(dataList[1]) * int(dataList[2]))
		employeeSales = searchEmployeeSales(employeeId)
		employeeSales[1] += price
	answerList = [data[0] for data in employeeSalesList if data[1] >= 1000000]
	if answerList:
		print('\n'.join(map(str, answerList)))
	else:
		print('NA')
	dataCount = int(input())


l = int(input())
while l != 0:
	k = 0
	A = []
	B = []
	for l in range(0, l):
		li = input().split()
		if li[0] in A:
			i = A.index(li[0])
			B[i] = B[i] + int(li[1]) * int(li[2])
		else:
			A.append(li[0])
			B.append(int(li[1]) * int(li[2]))
	for (j, b) in enumerate(B):
		if b >= 10 ** 6:
			print(A[j])
			k = 1
	if k == 0:
		print('NA')
	l = int(input())


from collections import OrderedDict
while True:
	n = int(input())
	if n == 0:
		break
	dic = OrderedDict()
	for i in range(n):
		line = input().split()
		key = line[0]
		sales = int(line[1]) * int(line[2])
		if key in dic:
			dic[key] += sales
		else:
			dic[key] = sales
	res = [k for k in dic if dic[k] >= 1000000]
	if len(res) == 0:
		print('NA')
	else:
		[print(k) for k in res]


while True:
	N = int(input())
	if N == 0:
		break
	D = {}
	di = []
	for n in range(N):
		(e, p, q) = input().split()
		p = int(p)
		q = int(q)
		if e not in di:
			di.append(e)
			D[e] = p * q
		else:
			D[e] = D[e] + p * q
	flag = 0
	for dj in di:
		if D[dj] >= 10 ** 6:
			print(dj)
			flag = 1
	if flag == 0:
		print('NA')


n = int(input())
while n != 0:
	earnings = []
	for i in range(0, n):
		a = str.split(input(), ' ')
		if i > 0:
			for j in range(0, len(earnings)):
				if a[0] == earnings[j][0]:
					earnings[j][1] = str(int(earnings[j][1]) + int(a[1]) * int(a[2]))
					break
				if j == len(earnings) - 1:
					earnings.append([a[0], str(int(a[1]) * int(a[2]))])
		else:
			earnings.append([a[0], str(int(a[1]) * int(a[2]))])
	milionear = []
	for i in range(0, len(earnings)):
		if int(earnings[i][1]) >= 1000000.0:
			milionear.append(earnings[i][0])
	if len(milionear) == 0:
		print('NA')
	else:
		for i in range(0, len(milionear)):
			print(milionear[i])
	n = int(input())


while 1:
	n = int(input())
	if not n:
		break
	f = 1
	L = {}
	for (a, b, c) in [input().split() for i in range(n)]:
		d = int(b) * int(c)
		if a in L:
			if L[a] >= 1000000.0:
				continue
			L[a] += d
		else:
			L[a] = d
		if L[a] >= 1000000.0:
			print(a)
			f = 0
	if f:
		print('NA')


import sys
while True:
	n = int(sys.stdin.readline().rstrip())
	if n == 0:
		break
	members = []
	sales = {}
	for i in range(n):
		(e, p, q) = sys.stdin.readline().rstrip().split(' ')
		if not e in members:
			members.append(e)
			sales[e] = 0
		sales[e] += int(p) * int(q)
	ret = [member for member in members if sales[member] >= 1000000]
	if len(ret) != 0:
		for d in ret:
			print(d)
	else:
		print('NA')


while 1:
	n = int(input())
	if not n:
		break
	f = 1
	L = {}
	for (a, b, c) in [input().split() for i in range(n)]:
		d = int(b) * int(c)
		if a in L:
			if L[a] >= 1000000.0:
				continue
			L[a] += d
		else:
			L[a] = d
		if L[a] >= 1000000.0:
			print(a)
			f = 0
	if f:
		print('NA')


from collections import OrderedDict
while True:
	n = int(input())
	if not n:
		break
	ds = OrderedDict()
	for _ in range(n):
		(i, p, q) = input().split()
		ds[i] = ds.get(i, 0) + int(p) * int(q)
	ds = OrderedDict(((i, v) for (i, v) in ds.items() if v >= 1000000))
	if ds:
		print('\n'.join(ds.keys()))
	else:
		print('NA')