#include <bits/stdc++.h>
using namespace std;
int main() {
  while (1) {
    int s[4000];
    int i;
    int w;
    w = 0;
    for (int y = 0; y < 4000; y++) {
      s[y] = 0;
    }
    cin >> i;
    if (i == 0) {
      break;
    }
    for (int y = 1; y <= i; y++) {
      int a, b, c;
      cin >> a >> b >> c;
      s[a - 1] = s[a - 1] + b * c;
    }
    for (int y = 0; y < 4000; y++) {
      if (s[y] >= 1000000) {
        cout << y + 1 << endl;
        w = 1;
      }
    }
    if (w == 0) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
