#include <bits/stdc++.h>
using namespace std;
int N[4000];
int main() {
  int count;
  while (cin >> count, count > 0) {
    map<int, int> m;
    int t = 1;
    queue<int> p;
    for (int i = 0; i < count; i++) {
      int t1, t2, t3;
      cin >> t1 >> t2 >> t3;
      if (N[t1 - 1] == 0) {
        N[t1 - 1] = t;
        t++;
        p.push(t1);
        m[t1] = 0;
      }
      m[t1] += t2 * t3;
    }
    bool flag = true;
    while (p.size()) {
      t = p.front();
      p.pop();
      if (m[t] >= 1000000) {
        cout << t << endl;
        flag = false;
      }
      N[t - 1] = 0;
    }
    if (flag) cout << "NA" << endl;
  }
  return 0;
}
