#include <bits/stdc++.h>
using namespace std;
int st[4444];
int stf[4444];
int main(void) {
  while (1) {
    int n;
    bool f = true;
    cin >> n;
    if (!n) break;
    memset(st, 0, sizeof(st));
    memset(stf, -1, sizeof(stf));
    for (int i = 0; i < n; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      st[a] += b * c;
      if (1000000 <= st[a] && stf[a]) {
        cout << a << endl;
        stf[a] = 0;
        f = false;
      }
    }
    if (f) puts("NA");
  }
}
