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: from collections import OrderedDict
while True:
    num = int(input())
    if not num: break
    result = OrderedDict()
    for _ in range(num):
        x, y, z = [int(el) for el in input().split(' ')]
        if x in result:
            result[x] += y*z
        else:
            result[x] = y*z
    res = [print(k) for k,v in result.items() if v >= 1e6]
    if not res: print('NA')

Python: while True:

    data_num = int(input())
    
    if data_num == 0:
        break

    nice_syatiku = 0

    for data_num in range(0,data_num,1):

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

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

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

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

    data = {}
    staff = []
    for i in range(n):
        tmp = list(map(int, input().split(' ')))
        if tmp[0] in data:
            data[tmp[0]] += tmp[1] * tmp[2]
        else:
            data[tmp[0]] = tmp[1] * tmp[2]
            staff.append(tmp[0])

    if max(data.values()) < 1000000:
        print('NA')
    else:
        for k in staff:
            if data[k] >= 1000000:
                print(k)

Python: while True:
    n = int(input())
    if n == 0:
        break
    ID = []
    sales = {}
    for i in range(n):
        ipq = list(map(int, input().split()))
        ID = ipq[0]
        pq = ipq[1] * ipq[2]
        if ID in sales:
            sales[ID] += pq
        else:
            sales[ID] = pq
    t = True
    for k, v in sales.items():
        if v >= 1000000:
            print(k)
            t = False
    if t:
        print("NA")

Python: def solve():
    N = int(input())
    if N == 0:
        return False
    E = []
    D = {}
    for i in range(N):
        e, p, q = map(int, input().split())
        E.append(e)
        D[e] = D.get(e, 0) + p*q
    cnt = 0
    for e in E:
        if D.get(e, 0) >= 1000000:
            print(e)
            del D[e]
            cnt += 1
    if cnt == 0:
        print("NA")
    return True
while solve():
    ...

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

    rs = {}
    for i in range(n):
        cid, p, q = map(int, input().strip().split(' '))
        rs[cid] = (rs.get(cid, None) or 0) + p * q

    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: while True:
    n = int(input())
    if n == 0: break
 
    data = {}
    staff = []
    for i in range(n):
        tmp = list(map(int, input().split(' ')))
        if tmp[0] in data:
            data[tmp[0]] += tmp[1] * tmp[2]
        else:
            data[tmp[0]] = tmp[1] * tmp[2]
            staff.append(tmp[0])
 
    if max(data.values()) < 1000000:
        print('NA')
    else:
        for k in staff:
            if data[k] >= 1000000:
                print(k)

Python: while True:
  N = input()
  if not N:
    break
  m = dict()
  for i in range(N):
    a, b, c = map(int, raw_input().split())
    m[a] = (m[a] if a in m else 0) + b * c
  l = [str(k) for k, v in m.items() if v >= 1000000 ]
  for i in l:
    print(i)
  if not len(l):
    print('NA')

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

input_lines = sys.stdin.readlines()
cnt = 0
dataset = []
for i in input_lines:
    if not(' ' in i):
        dataset.append([int(i)])
        cnt += 1
    else:dataset[cnt-1].append(list(map(int, i.split(' '))))
    
for d in dataset:
    if d == [0]:break
    shain = [[x[0], x[1]*x[2]] for x in d[1:]]
    #score = [ for x in d[1:]]
    slist = []
    for s in shain:
        if not(s[0] in slist):slist.append(s[0])
    newslist = [[x, 0] for x in slist]
    score = []
    for s in shain:
        newslist[slist.index(s[0])][1] += s[1]
    
    flag = False
    for n in newslist:
        if n[1] >= 1000000:
            print(n[0])
            flag = True
    if not flag:print('NA')

Python: while True:
    a = int(input())
    if a == 0:
        break
    lib = {}
    
    for _ in range(a):
        s,m,l = map(int, input().split())
        lib[s] = lib.get(s,0) + m*l
    
    if max(lib[x] for x in lib) <1000000:
        print("NA")
    else:
        for i in lib:
            if lib[i] >= 1000000:
                print(i)

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

Python: while True:
    n = int(input())
    if n == 0:
        break
    result = {}
    order = []
    for i in range(n):
        e, p, q = map(int, input().split())
        if e in result:
            result[e] += p*q
        else:
            result[e] = p*q
            order.append(e)
    flag = True
    for e_i in order:
        if result[e_i] >= 1000000:
            print(e_i)
            flag = False
    if flag:
        print("NA")

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')

Python: # Edit: 2014/09/25
# Lang: Python3
# Time: 0.xxs
#

if __name__ == "__main__":

    while True:
        d = {}
        n = int(input())
        if not n:
            break  # exit at n=0

        for i in range(n):
            s, p, m = map(int, input().strip("\n").split(" "))
            # s:社員番号, p:価格, m:販売戸数
            # print(s, p, m)

            if s in d:
                d[s] = d[s] + p * m
            else:
                d[s] = p * m

        cnt = 0
        for k, v in d.items():
            if v >= 1000000:
                print(k)
                cnt +=1
        if not cnt:
            print("NA")

        #print(d)

Python: x = 1
while x != 0:
    x = int(input().rstrip())
    frag = 0
    for j in range(x):
        A = input().sprit(" ")
        if int(A[1]) * int(A[2]) >= 1000000:
            print(A[0])
            flag = 1
    if flag == 0:
        print("NA")

Python: x = []
while True:
    n = int(input())
    if n == 0:
        break
    d = [0]*4000
    for i in range(n):
        e_t,p,q = map(int,input().split())
        d[e_t] += p*q
    flag = 0
    for i in range(4000):
        if d[i] >= 1000000:
            x.append(i)
            flag = 1
    if flag == 0:
        x.append('NA')
for i in range(len(x)):
    print(x[i])