#include <bits/stdc++.h>
using namespace std;
int main() {
  while (1) {
    int n;
    cin >> n;
    if (n == 0)
      break;
    else {
      int ara[100000], i, sum[100000];
      for (i = 0; i <= 4000; i++) {
        sum[i] = 0;
      }
      int id, b, c;
      for (i = 0; i < n; i++) {
        cin >> id >> b >> c;
        sum[id] += (b * c);
        ara[id] = id;
      }
      int ara2[100000], j = 0;
      for (i = 0; i <= 4000; i++) {
        if (sum[i] >= 1000000) {
          ara2[j] = ara[i];
          j++;
        }
      }
      if (j == 0)
        cout << "NA" << endl;
      else {
        sort(ara2, ara2 + j);
        for (int k = 0; k < j; k++) {
          cout << ara2[k] << endl;
        }
      }
    }
  }
}
