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

Python: while True:
    N = int(input())
    if N == 0:
        break
    d = {}
    for n in range(N):
        num, p, q = map(int, input().split())
        if num in d:
            d[num][1] += (p*q)
        else:
            d[num] = [n, p*q]
    else:
        fla = False
        for k, v in sorted(d.items(), key=lambda x: x[1][0]):
            if v[1] >= 1000000:
                print(k)
                fla = True
        else:
            if not fla:
                print('NA')

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 = [int(i) for i in 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: # -*- 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]