#include <bits/stdc++.h>
using namespace std;
class Input {
 public:
  int n;
  vector<int> numbers, tanka, num;
  bool input() {
    scanf("%d", &n);
    if (!n) {
      return false;
    }
    for (int i = 0; i < n; i++) {
      int s, t, u;
      scanf("%d%d%d", &s, &t, &u);
      numbers.push_back(s);
      tanka.push_back(t);
      num.push_back(u);
    }
    return true;
  }
};
class Solver : public Input {
 public:
  vector<int> solve() {
    map<int, int> data;
    for (int i = 0; i < n; i++) {
      int value = tanka[i] * num[i];
      int number = numbers[i];
      if (data.find(number) == data.end()) {
        data[number] = 0;
      }
      data[number] += value;
    }
    vector<int> ret;
    for (map<int, int>::iterator it = data.begin(); it != data.end(); it++) {
      if ((*it).second >= 1000000) {
        ret.push_back((*it).first);
      }
    }
    return ret;
  }
};
signed main() {
  while (true) {
    Solver solver;
    if (!solver.input()) {
      break;
    }
    vector<int> res = solver.solve();
    if (res.size() == 0) {
      cout << "NA" << endl;
    } else {
      for (int i = 0; i < res.size(); i++) {
        cout << res[i] << endl;
      }
    }
  }
  return 0;
}
