while True:

    n = int(eval(input()))

    if n == 0: break

    d = dict()

    order = []

    for _ in range(n):

        i, p, q = list(map(int, input().split()))

        d[i] = d[i]+p*q if i in d else p*q

        if i not in order: order.append(i)

    b = True

    for o in order:

        if d[o] > 999999:

            print(o)

            b = False

    if b: print("NA")
while True:

    n = int(eval(input()))

    if n == 0:

        break

    d = dict()

    sep = []

    for _ in range(n):

        i, p, q = list(map(int, input().split()))

        if i in d:

            d[i] += p*q

        else:

            d[i] = p*q

            sep.append(i)

    tmp = list([x for x in list(d.items()) if x[1] >= 1000000])

    if len(tmp):

        tmp = {t[0]: t[1] for t in tmp}

        for s in sep:

            if s in tmp:

                print(s)

    else:

        print("NA")
while True:
    n = int(eval(input()))
    if n == 0:
        break
    d = dict()
    order = []
    for _ in range(n):
        i, p, q = list(map(int, input().split()))
        d[i] = d[i] + p * q if i in d else p * q
        if i not in order:
            order.append(i)
    b = True
    for o in order:
        if d[o] > 999999:
            print(o)
            b = False
    if b:
        print("NA")

while True:
    n = int(eval(input()))
    if n == 0:
        break
    d = dict()
    sep = []
    for _ in range(n):
        i, p, q = list(map(int, input().split()))
        if i in d:
            d[i] += p * q
        else:
            d[i] = p * q
            sep.append(i)
    tmp = list([x for x in list(d.items()) if x[1] >= 1000000])
    if len(tmp):
        tmp = {t[0]: t[1] for t in tmp}
        for s in sep:
            if s in tmp:
                print(s)
    else:
        print("NA")

-    order = [] +    sep = [] -        d[i] = d[i] + p * q if i in d else p * q -        if i not in order: -            order.append(i) -    b = True -    for o in order: -        if d[o] > 999999: -            print(o) -            b = False -    if b: +        if i in d: +            d[i] += p * q +        else: +            d[i] = p * q +            sep.append(i) +    tmp = list([x for x in list(d.items()) if x[1] >= 1000000]) +    if len(tmp): +        tmp = {t[0]: t[1] for t in tmp} +        for s in sep: +            if s in tmp: +                print(s) +    else: