#include <iostream>
using namespace std;
int main() {
  bool f;
  int n, a, b, c, d, e;
  while (cin >> n && n > 0) {
    d = e = f = 0;
    while (n--) {
      cin >> a >> b >> c;
      if (a != d) {
        e = 0;
      }
      e += b * c;
      if (e >= 1000000) {
        cout << a << endl;
        f = 1;
      }
      d = a;
    }
    if (!f) {
      cout << "NA" << endl;
    }
  }
  return 0;
}