#include <bits/stdc++.h>
using namespace std;
static const double EPS = 1e-5;
struct man {
  int num;
  int money;
};
int main() {
  int n;
  while (true) {
    cin >> n;
    if (n == 0) exit(0);
    vector<man> d;
    d.clear();
    for (int i = 0; i < n; i++) {
      int num, a, b;
      bool ch = false;
      cin >> num;
      cin >> a;
      cin >> b;
      for (int j = 0; j < d.size(); j++) {
        if (d[j].num == num) {
          d[j].money = d[j].money + a * b;
          ch = true;
          break;
        }
      }
      if (ch == false) {
        struct man x;
        x.num = num;
        x.money = a * b;
        d.push_back(x);
      }
    }
    int count = 0;
    for (int j = 0; j < d.size(); j++)
      if (d[j].money >= 1000000) {
        cout << d[j].num << endl;
        count++;
      }
    if (count < 1) cout << "NA" << endl;
  }
}
