Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}

		sales := make([]int, 4000)
		members := make([]int, 0)
		memberCheck := make(map[int]bool)

		for i := 0; i < n; i++ {
			scanner.Scan()
			input := strings.Split(scanner.Text(), " ")
			e, _ := strconv.Atoi(input[0])
			p, _ := strconv.Atoi(input[1])
			q, _ := strconv.Atoi(input[2])

			if e >= 1 && e <= 4000 && memberCheck[e] == false {
				members = append(members, e)
				memberCheck[e] = true
			}
			sales[e-1] += p * q
		}

		emptyFlag := true
		for _, v := range members {
			if sales[v-1] >= 1000000 {
				fmt.Println(v)
				emptyFlag = false
			}
		}

		if emptyFlag == true {
			fmt.Println("NA")
		}
	}
}

Python: while True:
    n = int(input())
    if n == 0:
        break

    lst = [0]*4001
    elst = []
    ans = []
    for i in range(n):
        e, p, q = map(int, input().split())
        if lst[e]:
            pass
        else:
            elst.append(e)

        lst[e] = lst[e] + p*q

    for i in elst:
        if lst[i] >= 1000000:
            ans.append(i)

    if ans == []:
        print('NA')
    
    else:
        for i in ans:
            print(i)

Python: while True:
    n = int(input())
    if n != 0:
        dic = {}
        initno,initprice,initsales = map(int,input().split(" "))
        total = initsales*initprice
        dic[initno] = total
        for i in range(n-1):
            no, price, sales = map(int, input().split(" "))
            for k,v in dic.items():
                if k == no:
                    total = dic[no]
                    dic[no] = total + price*sales
                    break
                else:
                    dic[no] = price*sales
                    break


        cnt = 0
        for k,v in sorted(dic.items()):
            if v >= 1000000:
                print("%s" %(str(k)))
                cnt += 1
            else:
                pass

        if cnt == 0:
            print("NA")
        else:
            pass
    else:
        break

Python: while True:
    n = int(input())
    if n == 0:
        break
    d = dict()
    sep = []
    for _ in range(n):
        i, p, q = map(int, input().split())
        if i in d:
            d[i] += p*q
        else:
            d[i] = p*q
            sep.append(i)
    tmp = list(filter(lambda x: x[1] >= 1000000, d.items()))
    if len(tmp):
        tmp = {t[0]: t[1] for t in tmp}
        for s in sep:
            if s in tmp:
                print(s)
    else:
        print("NA")

Python: while True:
	n=int(input())
	if n:
		a=[list(map(int,input().split())) for _ in range(n)]
		b={}
		for i in range(n):
			if a[i][0] in b:
				b[a[i][0]]+=a[i][1]*a[i][2]
			else:
				b[a[i][0]]=a[i][1]*a[i][2]
		for k in b.keys():
			if b[k]>=1000000:
				print(k)
		if max(k.values())<1000000:
			print("NA")
	else:
		break

Python: while True:
    n=int(input())
    if n==0:break
    d=dict()
    for _ in range(n):
        i,p,q=map(int, input().split())
        d[i] = d[i]+p*q if i in d else p*q
    b=True
    for k, v in d.items():
        if v >= 1000000:
            print(k)
            b=False
    else:
        if b:print("NA")

Python: #!/usr/bin/env python3
import sys

input_lines = sys.stdin.readlines()
cnt = 0
dataset = []
for i in input_lines:
    print('s')

Python: data_num = int(input())

nice_syatiku = 0

for data_num in range(data_num):

    a,b,c = map(int,input().split())

    Earnings = b * c
    
    if Earnings >= 1000000:
        print(a)
        nice_syatiku += 1

if nice_syatiku == 0:
    print("NA\n")

Python: while(True):
    n = int(input())
    if n == 0:
         break
    oe = []
    for i in range(n):
        e,p,q = map(int, input().split())
        for a in oe:
            if a[0] == e:
                a[1] += p*q
                continue
        oe.append([e,p*q])
    lis = [ a[0] for a in oe if a[1] >= 1000000]
    if len(lis):
        print("\n".join(str(l) for l in lis))
    else:
        print("NA")

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

Python: while(True):
    n = int(input())
    if n==0: break
    d = dict()
    c = 0
    for _ in range(n):
        id_,p,q = map(int,input().split())
        if id_ in d:
            d[id_] += p*q
        else:
            d[id_] = p*q
    for i in d:
        if d[i] >= 1000000:
            print(i)
            c+=1
    if c == 0: print('NA')

Python: while(True):
    n = int(input())
    if n==0: break
    d = dict()
    s = set()
    l = list()
    for _ in range(n):
        id_,p,q = map(int,input().split())
        if id_ in s:
            d[id_] += p*q
        else:
            s.add(id_)
            d[id_] = p*q
    for i in s:
        if d[i] >= 1000000:
            l.append(i)
    if len(l) == 0:
        print('NA')
    else:
        for i in sorted(l):
            print(i)

Python: while True:
	n=int(input())
	if n==0: break
	a=[list(map(int,input().split())) for _ in range(n)]
	d={}
	for i in range(n):
		if a[i][0] in d:
			d[a[i][0]]+=a[i][1]*a[i][2]
		else:
			d[a[i][0]]=a[i][1]*a[i][2]
	for k in d.keys():
		if d[k]>=1000000:
			print(k)
	if max(d.values())<1000000:
		print("NA")

Python: while True:
  N = input()
  if not N:
    break
  m = dict()
  o = []
  for i in range(N):
    a, b, c = map(int, raw_input().split())
    o.append(a)
    m[a] = (m[a] if a in m else 0) + b * c
  oo = []
  for x in o:
    if x not in oo:
      oo.append(x)
  for i in oo:
    if m[i] >= 1000000:
      print(i)
  if max(m.values()) < 1000000:
    print('NA')

Python: # coding: utf-8
# Here your code !
def searchEmployeeSales(employeeId):
    for data in employeeSalesList:
        if data[0] == employeeId:
            return data
    
    newData = [employeeId, 0]
    employeeSalesList.append(newData)
    return newData

def printEmployeeOfDataset():
    answerList = [data[0] for data in employeeSalesList if data[1] >= 1000000]
    if answerList:
        print("\n".join(map(str, answerList)))
        return
    print("NA")

dataCount = int(input())
while dataCount > 0:
    employeeSalesList = []
    for _ in range(dataCount):
        employeeId, price, volume = list(map(int, input().split(" ")))
        employeeSales = searchEmployeeSales(employeeId)
        employeeSales[1] += price * volume
    printEmployeeOfDataset()
    dataCount = int(input())

Python: while True:
    n = input()
    if n == 0:
        break

    rs = {}
    for i in range(n):
        arr = input().split(' ')
        s = arr[0] * arr[1]
        rs[arr[0]] = (rs[arr[0]] or 0) + s

    top = [k for k, v in rs.items if v > 1000000]
    if len(top) == 0:
        print('NA')
    else:
        for i in top:
            print(i)

Python: num=int(input())
emp=[]
cnt=0
for i in range(num):
    emp.append(num)
    emp[i]=[int(k) for k in input().split()]
for i in range(num):
    for q in range(i+1,num):
        if emp[i][0]==emp[q][0]:
            emp[i][1]=emp[i][1]+emp[q][1]
            emp[i][2]=emp[i][2]+emp[q][2]
            emp[q][1],emp[q][2]=0,0
    if emp[i][1]*emp[i][2]>=1000000:
        print(emp[i][0])
        cnt+=1
if cnt==0:
    print('NA')