Go: package main

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

func main() {
	stdin := bufio.NewScanner(os.Stdin)

	for stdin.Scan() {
		n, _ := strconv.Atoi(stdin.Text())
		if n == 0 {
			break
		}
		sales := make(map[string]int)
		existed := make(map[string]bool)
		order := make([]string, 4000)
		flg := false
		for i := 0; i < n; i++ {
			stdin.Scan()
			l := strings.Split(stdin.Text(), " ")
			e := l[0]
			p, _ := strconv.Atoi(l[1])
			q, _ := strconv.Atoi(l[2])
			sales[e] += p * q
			if !existed[e] {
				order = append(order, e)
				existed[e] = true
			}
		}
		for _, v := range order {
			if sales[v] >= 1000000 {
				fmt.Println(v)
				flg = true
			}
		}
		if flg == false {
			fmt.Println("NA")
		}
	}
}

Python: while True:
    try:
        n=int(input())
    except:
        break
    if n==0:
        break
    data={}
    staff=[]
    for i in range(n):
        spam=list(map(int,input().split()))
        if spam[0] in data.keys():
            data[spam[0]]+=spam[1]*spam[2]
        else:
            data[spam[0]]=spam[1]*spam[2]
            staff.append(spam[0])
    if max(data.values())<1000000:
        print('NA')
    else:
        for i in staff:
            if data[i] >= 1000000:
                print(i)

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
    ans=[]
    for k, v in d.items():
        if v >= 1000000:
            ans.append(k)
            b=False
    else:
        if b:print("NA")
        else:print('\n'.join(map(str, ans)))

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

Python: from collections import defaultdict
while True:
    n = int(input())
    if n == 0:
        break

    SALES = defaultdict(int)
    for _ in range(n):
        id, p, num = [int(x) for x in input().split()]
        SALES[id] += p * num
        
    L = [k for k, v  in SALES.items() if v >= 1000000]

    if len(L) > 0:
        for i in L:
            print(i)
    else:
        print("NA")

Python: 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:
            print(i)
            flag = 1
    if flag == 0:
        print('NA')

Python: while True:
  n = int(input())
  if n == 0:
    break
  c = 0
  l = []
  d = {}
  for i in range(n):
    num,x,y = map(int,input().split())
    if num in d:
      d[num] = d[num] + x*y
    else:
      d[num] = x*y
      l.append(num)
  for i in l:
    if d[i] >= 1000000:
      print(i)
      c += 1
  if c == 0:
    print('NA')

Python: # AOJ 0100 Sale Result
# Python3 2018.6.17 bal4u

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

	id = []
	pq = [-1]*4001
	for i in range(n):
		e, p, q = list(map(int, input().split()))
		if pq[e] < 0:
			id.append(e)
			pq[e] = p*q
		else: pq[e] += p*q
		
	f = False
	for e in id:
		if pq[e] >= 1000000:
			print(e)
			f = True
	if not f: print('NA')

Python: #!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin, exit
from collections import Counter


def main(readline=stdin.readline):
    count = Counter()
    member = []

    while 1:
        n = int(readline())
        if not n:
            exit()

        count.clear()
        del member[:]

        for _ in range(n):
            i, price, num = (int(s) for s in readline().split())
            count[i] += price * num
            if i not in member:
                member.append(i)

        member = [i for i in member if count[i] >= 1000000]

        if member:
            print(*member, sep='\n')
        else:
            print('NA')


if __name__ == '__main__':
    main()

Python: 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]

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

  inputs=[None]*n
  for t in range(0,n):
    inputs[t] = list(map(int,input().split()))

  sale_result={}
  for t in range(0,n):
    sale_result[inputs[t][0]]=0 # inputs[t][0] means the ID in the "n"th line.

  for t in inputs:
    sale_result[t[0]]+=t[1]*t[2]

  na=True
  for k in sale_result:
    if sale_result[k]>=1000000:
      print(k)
      na=False
  if na:
    print("NA")

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

Python: while(True):
    n = int(input())
    if n==0: break
    d = dict()
    s = set()
    c = 0
    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:
            print(i)
            c+=1
    if c == 0: print('NA')

Python: 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]>=1e6:continue
      L[a]+=int(b)*int(c)
    else:L[a]=int(b)*int(c)
    if L[a] >= 1e6:print(a);f=0
  if f:print('NA')

Python: while True:
    n=int(input())
    if n==0:
        break
    s=[-1]*4001
    id=[]
    for i in range(n):
        e,p,q=map(int,input().split())
        if s[e]<0:
            id.append(e)
            s[e]=p*q
        else:
            s[e]+=p*q
    ch=True
    for i in id:
        if s[i]>=1000000:
            print(i)
            ch=False
    if ch:
        print("NA")

Python: 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")

Python: while True:
    num = int(input())
    if not num:
        break
    data = [[int(el) for el in input().split(' ')] for _ in range(num)]
    tmp = [i for i,j,k in data if j*k >= 1e6]
    seen = set()
    seen_add = seen.add
    result = [x for x in tmp if x not in seen and not seen_add(x)]
    if not result:
        print('NA')
    else:
        [print(r) for r in result]

Python: while True:
    num = int(input())
    if not num:
        break
    data = [[int(el) for el in input().split(' ')] for _ in range(num)]
    tmp = [i for i,j,k in data if j*k >= 1e6]
    seen = set()
    seen_add = seen.add
    result = [x for x in tmp if x not in seen and not seen_add(x)]
    if not result:
        print('NA')
    else:
        [print(r) for r in result]

Python: while True:

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

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