import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    int n;
    while ((n = readint) > 0) {
        int[] ids;
        long[int] m;
        for (int i = 0; i < n; i++) {
            auto xs = readints;
            int no = xs[0];
            long a = xs[1];
            long b = xs[2];
            m[no] += a * b;
            if (!ids.canFind(no)) {
                ids ~= no;
            }
        }

        bool none = true;
        foreach (id; ids) {
            if (m[id] >= 1_000_000) {
                writeln(id);
                none = false;
            }
        }
        if (none)
            writeln("N/A");
    }
}