#include <iostream>
using namespace std;

int main() {
    int i[4000], p, q, sum[4000];
    for (; ; ) {
        int n, count;
        cin>>n;
        if (n) {
            count = 0;
            for (int j = 0; j < n; j++) {
                cin>>i[j]>>p>>q;
                sum[j] = p * q;
                if (j == 0 && sum[j] >= 1000000) {
                    cout<<i[j]<<endl;
                    count++;
                }
                for (int k = 0 ; k < j; k++) {
                    if (i[k] == i[j]) {
                        if (sum[k] >= 1000000) {
                            break;
                        } else {
                            sum[k] += sum[j];
                            if (sum[k] >= 1000000) {
                                cout<<i[j]<<endl;
                                count++;
                            }
                            break;
                        }
                    }
                }
            }
            if (count == 0) {
                cout<<"NA"<<endl;
            }
        } else
            break;
    }
    return 0;
}