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

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()
 
main()