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:
    n = int(input())
    if n == 0:
        break
    flag = False
    dic = {}
    for j in range(n):
        i,p,q = map(int, input().split())
        if i not in dic:
            dic[i] = [p*q, 0]
        else:
            dic[i][0] += p*q
        
        if dic[i][0] >= 10**6 and dic[i][1] == 0:
            print(i)
            dic[i][1] = 1
            flag = True
    if flag == False:
        print("NA")

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

    data = {}
    ans = []
    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]

    if max(data.values()) < 1000000:
        print('NA')
    else:
        for k in data.keys():
            if data[k] >= 1000000:
                print(k)

Python: class Employee():
    def __init__(self,id,p,q):
        self.id = id
        self.total = p*q
    
    def add_total(self,total):
        self.total += total

class Manager():
    def __init__(self):
        self.employees = list()
        self.count = 0
    
    def add(self,e):
        if len(self.employees) == 0:
            self.employees.append(e)
        else:
            if self.employees[-1].id == e.id:
                self.employees[-1].add_total(e.total)
            else:
                self.employees.append(e)
            
    def pprint(self):
        for i,e in enumerate(self.employees):
            if e.total >= 1000000:
                print(e.id)
                self.count+=1
        if self.count == 0:
            print("NA")

def main():
    while(True):
        m = Manager()
        n = int(input())
        if n==0:
            break
        l = list()
        for i in range(n):
            s = list(map(int,input().split()))
            l.append(s)
        l = sorted(l)
        for x in l:
            m.add(Employee(*x))
        m.pprint()
    

if __name__=="__main__":
    main()

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()))
    #inputs == [[i0,p0,q0],[i1,p1,q1],[i2,p2,q2]]

  id_sale = [] # id_sale == [id,sale,id,sale,id,sale]
  for i in inputs: # i == [ik,pk,qk]
    try:
      id_sale[id_sale.index(i[0])+1] += i[1]*i[2]
    except ValueError:
      id_sale += [i[0],i[1]*i[2]]

  na=True
  for i in range(0,len(id_sale),2):
    if id_sale[i+1] >= 1000000:
      print(id_sale[i])
      na=False
  if na == True:
    print("NA")

Python: while True:
    n = int(input())
    if n == 0:
        break
    ID = []
    sales = {}
    for i in range(n):
        ipq = list(map(str, input().split()))
        ID = ipq[0]
        pq = int(ipq[1]) * int(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: num = int(input())
if not num:
    exit()
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 True:
    input_n = int(input())
    key = 0
    if input_n == 0:
        break
    id_list = [[0 for i in range(2)]for i in range(input_n)]
    for i in range(input_n):
        id_line = input().split()
        for j in id_list:
            if j[0] == int(id_line[0]):
                j[1] += int(id_line[1]) * int(id_line[2])
                uriage = j[1]
                break
        else:
            id_list[i][0] = int(id_line[0])
            id_list[i][1] = int(id_line[1]) * int(id_line[2])
            uriage = id_list[i][1]
        if uriage >= 1000000:
            key = 1
    
    for i in id_list:
        if key == 0:
            print("NA")
            break
        if i[1] >= 1000000:
            print(i[0])

Python: # Edit: 2014/09/25
# Lang: Python3
# Time: 0.xxs
#

from collections import OrderedDict

if __name__ == "__main__":

    while True:
        d = OrderedDict()
        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(" "))
            # print(s, p, m)

            if s in d:
                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")

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

def parseData(line):
    dataList = line.split(" ")
    return int(dataList[0]), int(dataList[1]) * int(dataList[2])

dataCount = int(input())
while dataCount > 0:
    employeeSalesList = []
    for _ in range(dataCount):
        employeeId, price = parseData(input())
        found = False
        for data in employeeSalesList:
            if data[0] == employeeId:
                data[1] += price
                found = True
        if not found:
            employeeSalesList.append([employeeId, price])

    answerList = [data[0] for data in employeeSalesList if data[1] >= 1000000]
    if answerList:
        print("\n".join(map(str, answerList)))
    else:
        print("NA")

    dataCount = int(input())

Python: dataCount = int(input())
while dataCount > 0:
    employeeSalesList = []
    for _ in range(dataCount):
        dataList = input().split(" ")
        employeeId, price = dataList[0], int(dataList[1]) * int(dataList[2])
        for data in employeeSalesList:
            if data[0] == employeeId:
                data[1] += price
                continue
        employeeSalesList.append([employeeId, price])

    answerList = [data[0] for data in employeeSalesList if data[1] >= 1000000]
    if answerList:
        print("\n".join(map(str, answerList)))
    else:
        print("NA")

    dataCount = int(input())

Python: while True:
    n=int(input())
    if n==0:break
    res={}
    li=[]
    for i in range(n):
        d=[int(num) for num in input().split(' ')]
        res[d[0]-1]+=d[1]*d[2]
        if d[0]-1 not in li:li.append(d[0]-1)
    flag=False
    for i in li:
        if res[i]>=1000000:
            print(i+1)
            flag=True
    if flag==False:print("NA")

Python: from collections import OrderedDict

while True:
    n = int(input())
    if n == 0:
        break
    ans = OrderedDict()
    for i in range(n):
        e, p, q = [int(x) for x in input().split()]
        if e in ans:
            ans[e] += p * q
        else:
            ans[e] = p * q
    flag = True
    for k, v in ans.items():
        if v >= 1000000:
            flag = False
            print(k)
    if flag:
        print('NA')