#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (1) {
    cin >> n;
    if (n == 0) break;
    int a[4001], f[4001];
    for (int i = 0; i < 4001; i++) a[i] = 0;
    for (int i = 0; i < 4001; i++) f[i] = 0;
    int b, c, d;
    int s = 0;
    for (int i = 0; i < n; i++) {
      cin >> b >> c >> d;
      if (a[b] < 1000000) a[b] += c * d;
      if (f[b] == 0) {
        s++;
        f[b] = s;
      }
    }
    bool e = true;
    for (int i = 1; i < 4001; i++) {
      for (int j = 0; j < 4001; j++) {
        if (f[j] != i) continue;
        if (a[j] >= 1000000) {
          e = false;
          cout << j << endl;
        }
        break;
      }
    }
    if (e) cout << "NA" << endl;
  }
}
