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: # 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: while True:
    n = int(input())
    if n == 0:
        break
    emp = [0] * 4001
    used = set()
    for i in range(n):
        e, p, q = map(int, input().split())
        emp[e] += p * q
        if 1000000 <= emp[e] and e not in used:
            print(e)
            used.add(e)
    if len(used) == 0:
        print("NA")

Python: 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: # coding:utf-8

while (True):
    inputCount = int(input())

    if inputCount == 0:
        break

    employeeNumber = []
    employeePrice = []

    while 0 < inputCount:
        inputNum = [int(item) for item in input().split(" ")]

        price = inputNum[1] * inputNum[2]

        if inputNum[0] in employeeNumber:
            index = employeeNumber.index(inputNum[0])
            employeePrice[index] += price
        else:
            employeeNumber.append(inputNum[0])
            employeePrice.append(price)

        inputCount -= 1

    isExist = False

    for index in range(0, len(employeeNumber)):
        if 1000000 <= employeePrice[index]:
            print(employeeNumber[index])
            isExist = True

    if not isExist:
        print("NA")

Python: # coding: utf-8
# Here your code !

from collections import defaultdict as dd
while True:
    n=int(input())
    if n==0:
        break
    data=dd(int)
    for i in range(n):
        a,b,c=map(int,input().split())
        data[a]+=b*c
    f=False
    for i,j in data.items():
        if j>=1000000:
            print(i)
            f=True
    if not f:
        print("NA")

Python: while True:
    str = input()
    if len(str) == 1 and not str == "0":
        datadic={}
        nn = len(str)
        for ii in range(nn):
            data = input.stlip()
            datadic[data[0]] = int(data[1]) * int(data[2])
        print(datadic[ max( datadic.values() ) ])

Python: while 1:
    n=int(input())
    if n==0:break
    a={};c=[]
    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];c.append(b[0])
    if max(a.values())<=999999:print('NA' )
    for i in c:
        if a[i]>999999:print(i)

Python: 


while True:
    n=int(input())
    if n==0:
        break
    else:
        for i in range(n):
            k=0
            l=map(int, input().split())
            if l[1]*l[2]>=1000000:
                print(l[0])
                k+=1
        if k==0:
            print("NA")

Python: n = int(input())
while (n != 0):
    e_ab = {}
    for i in range(n):
        e,a,b = map(int, input().split())
        ab = a*b
        if (e not in e_ab.keys()):
            e_ab[e] = ab
        else:
            e_ab[e] += ab
    c = 0
    for e,ab in e_ab.items():
        if (ab >= 10**6):
            c += 1
            print(e)
    if (c == 0):
        print('NA')
    
    n = int(input())

Python: while True:
    n = int(input())
    if n == 0:
        break
    save_list=[0]*4001
    display_list = []
    for i in range(n):
        a,b,c =  map(int, input().split())
        save_list[a] += b * c
        if a not in display_list:
            display_list.append(a)
    ans = []
    for i in display_list:
        if save_list[i] >= 1000000:
            ans.append(i)
    if not ans:
        print("NA")
    else:
        for i in ans:
            print(i)

Python: p = []
q = []
while True:
    n = int(input())
    m = 0
    number = [0] * 4000
    if n == 0:
        break
    else:
        for i in range(n):
            p.append(i)
            q.append(i)
            e,p[i],q[i] = [int(s) for s in input().split(' ')]
            if number[e] >= 1000000:
                break
            else:
                number[e] = number[e] + p[i] * q[i]
                if number[e] >= 1000000:
                    print(e)
                else:
                    m = m + 1
            if m == n:
                print('NA')

Python: while 1:
    n=int(input())
    if n==0:break
    a={};c=[]
    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];c.append(b[0])
    if max(a.values())<=999999:print('NA' )
    for i in c:
        if a[i]>999999:print(i)

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

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

import sys
import os
import math
from collections import defaultdict

for s in sys.stdin:
    n = int(s)
    if n == 0:
        break

    d = defaultdict(int)
    for i in range(n):
        e, p, q = map(int, input().split())
        d[e] += p * q

    is_exist = False
    for k, v in d.items():
        if v >= 1000000:
            print(k)
            is_exist = True

    if not is_exist:
        print('NA')

Python: from collections import OrderedDict

while True:
    n = int(input())
    if not n:
        break
        
    ds = OrderedDict()
    for _ in range(n):
        i, p, q  = input().split()
        ds[i] = ds.get(i, 0) + int(p) * int(q)
    
    ds = OrderedDict((i, v) for i, v in ds.items() if v >= 1000000)
    if ds:
        print('\n'.join(ds.keys()))
    else:
        print('NA')

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

while True:
    str = sys.stdin.readline().stlip()
    if len(str) == 1 and not str == "0":
        datadic={}
        nn = len(str)
        for ii in range(nn):
            data = sys.stdin.readline().stlip()
            datadic[data[0]] = int(data[1]) * int(data[2])
        print(datadic[ max( datadic.values() ) ])
    else:
        break