#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, id, i, k, f, a, b, da[4001], jun[4001], ch[4001];
  while (cin >> n) {
    if (n == 0) break;
    memset(da, 0, sizeof(da));
    memset(ch, 0, sizeof(ch));
    k = 0;
    for (i = 0; i < n; i++) {
      cin >> id >> a >> b;
      da[id] += a * b;
      if (ch[id] == 0 && da[id] > 999999) {
        ch[id] = 1;
        jun[k++] = id;
      }
    }
    f = 0;
    for (i = 0; i < k; i++)
      if (da[jun[i]] >= 1000000) {
        cout << jun[i] << endl;
        f = 1;
      }
    if (f == 0) cout << "NA" << endl;
  }
  return 0;
}
