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:
    num = int(input())
    if not num:
        break
    data = [[int(el) for el in input().split(' ')] for _ in range(num)]
    result = [print(i) for i,j,k in data if j*k >= 1e6]
    if not result:
        print('NA')

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

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

Python: while True:
    num = int(input())
    if not num:
        break
    data = [[int(el) for el in input().split(' ')] for _ in range(num)]
    result = [print(i) for i,j,k in data if j*k >= 1e6]
    if not result:
        print('NA')

Python: while 1:
    n=int(input())
    if n==0:break
    count=0
    member=[0]*4001
    mem_check=[]
    mem_check2=[]
    for i in range(n):
        e,p,q=map(int,input().split())
        member[e]+=p*q
        mem_check.append(e)
    for i in mem_check:
        if not(i in mem_check2):
            if member[i]>=1000000:
                print(i)
                count+=1
                mem_check2.append(i)
    if count==0:
        print("NA")

Python: from pip._vendor.distlib.compat import raw_input
while True:
    n = int(raw_input())
    if n == 0: break
    data = {}
    order = []
    for i in range(n):
        id,price,quant = map(int, raw_input().split())
        if id in data:
            data[id] += price * quant
        else:
            data[id] = price * quant
            order.append(id)

    if max(data.values()) < 1000000: print("NA")
    else:
        for i in order:
            if data[i] >= 1000000:
                print(i)

Python: 
if __name__ == '__main__':

    list = []

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

        isNA = True

        for i in range(n):
            ds = input().split()
            e = ds[0]
            p = int(ds[1])
            q = int(ds[2])

            sales = p * q

            if (1000000 <= sales):
                list.append(e)
                isNA = False

        if isNA:
            list.append("NA")

    for l in list:
        print("%s" % l)

Python: while True:
	n = int(input())
	if n == 0:
		break
	else:
		greatworkers = []
		for i in range(n):
			person, price, number = [int(i) for i in input().split()]
			if person in greatworkers:
				pass
			elif price * number >= 1000000:
				greatworkers.append(str(person))
		if greatworkers == []:
			print('NA')
		else:
			print('\n'.join(greatworkers))

Python: # -*- coding: utf-8 -*-

import sys

while True:
	n = int(input())
	j = 0
	if n == 0:
		break
	salesmap = [0 for i in range(0,4001)]
	for i in range(n):
		a = input().split()
		salesmap[int(a[0])] += int(a[1])*int(a[2])
	for i in range(1,4001):
		if salesmap[i] >= 1000000:
			j += 1
			print(str(i))
	if j == 0:
		print('NA')
#print a # [a1, a2, a3, ..., aN]

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: import sys
import math

data =[0 for i in range(4000)]
p_data = []
while True:
	n = int(input())
	count = 0
	if n == 0:
		break
	for i in range(n):
		e,p,q = map(int, input().split())
		data[e] = data[e] + p * q
		if p_data.count(e) == 0:
			p_data.append(e)
	for i in range(len(p_data)):
		if data[p_data[i]] >= 1000000:
			print(p_data[i])
			count = count + 1
			data[p_data[i]] = 0
		elif data[p_data[i]] != 0:
			data[p_data[i]] = 0
	if count == 0:
		print('NA')
	p_data.clear()

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

Python: from collections import defaultdict

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

    dv = defaultdict(int)
    for _ in range(n):
        e, p, q = list(map(int, input().split()))
        dv[e] += p * q
    
    count = 0
    for k, v in dv.items():
        if v >= 1000000:
            print(k)
            count += 1
    if count == 0:
        print("NA")

Python: while True:
    N = int(input())
    if N == 0:
        break
    fla = False
    for n in range(N):
        num, p, q = map(int, input().split())
        if p*q >= 1000000:
            print(num)
            fla = True
    else:
        if not fla:
            print('NA')

Python: data_num = 1

while(data_num != 0):

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

Python: n = int(input())
while n != 0:
    score = {}
    for i in range(n):
        e,p,q = list(map(int,input().split()))
        if e in score:
            score[e] += p*q
        else:
            score[e] = p*q
    f = True
    for e,v in score.items():
        if v >= 1000000:
            print(e)
            f = False
    if f:
        print("NA")
    n = int(input())

Python: while 1:
    n=input()
    if n==0:break
    a=[0]*n
    s=[]
    for i in xrange(n):
        a[i]=map(int,raw_input().split())
    for i in xrange(n):
        if a[i][1]*a[i][2]>=10**6:
            s.append(a[i][0])
        else:
            pass
    if s==[]:
        print("NA")
    else:
        for i in xrange(len(s)):
            print(s[i])

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