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

Python: while 1:
 a={};b=0
 n=int(input())
 if n==0:break
 for _ in[0]*n:
  e,p,q=map(int,input().split())
  a.setdefault(e,0);a[e]+=p*q
 for e in a:
  if a[e]>=1e6:print(e);b=1
 if b:print('NA')

Python: while True:
    try:
        num = int(input())
    except:
        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:
    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 = -1
    for k, v in sales.items():
        if v >= 1000000:
            print(k)
            t = 1
    if t == -1:
        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: 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

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:
    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: # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0100&lang=jp
"""
import sys
from collections import OrderedDict


def solve(data):
    # ?£???????1,000,000??\????????????ID?????????
    # ??????????????????????????°????????´??????????????????ID?????\??????????????????????????????????????????
    sums = OrderedDict()
    for id, p, q in data:
        if id in sums:
            sums[id] += p * q
        else:
            sums[id] = p * q
    result = [key for key, value in sums.items() if value >= 1000000]
    return result



def main(args):
    #data = []
    #data.append([1001, 2000, 520])
    #data.append([1002, 1800, 450])
    #data.append([1003, 1600, 625])
    #data.append([1001, 200, 1220])
    while True:
        num = int(input())
        if num == 0:
            break
        data = []
        for _ in range(num):
            data.append([int(x) for x in input().split(' ')])
        result = solve(data)
        if result:
            for ele in result:
                print(ele)
        else:
            print('NA')


if __name__ == '__main__':
    main(sys.argv[1:])

Python: while 1:
 a={};b=1
 n=int(input())
 if n==0:break
 for _ in[0]*n:
  e,p,q=map(int,input().split())
  a.setdefault(e,0);a[e]+=p*q
 for e in a:
  if a[e]>=1e6:print(e);b=0
 if b:print('NA')

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)
    d=b*c
    if a in L:
      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: #!/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 = []

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

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()) < 1e6:
        print('NA')
    else:
        for k in staff:
            if data[k] >= 1e6:
                print(k)