#include <bits/stdc++.h>
using namespace std;
struct tEmploy {
  int num;
  int sold;
  tEmploy() {
    num = -1;
    sold = 0;
  }
};
int main() {
  while (1) {
    tEmploy *emp;
    int n;
    cin >> n;
    if (n == 0) {
      break;
    }
    emp = new tEmploy[n];
    for (int i = 0; i < n; i++) {
      int num, val, amo;
      cin >> num >> val >> amo;
      int j = 0;
      for (; j < n; j++) {
        if (emp[j].num == num) break;
      }
      if (j == n) {
        for (j = 0; j < n; j++) {
          if (emp[j].num == -1) {
            emp[j].num = num;
            break;
          }
        }
      }
      emp[j].sold += val * amo;
    }
    bool exist = false;
    for (int i = 0; (emp[i].num != -1) && (i < n); i++) {
      if (emp[i].sold >= 1000000) {
        cout << emp[i].num << endl;
        exist = true;
      }
    }
    if (!exist) {
      cout << "NA" << endl;
    }
    delete[] emp;
    emp = 0;
  }
  return 0;
}
