#include <bits/stdc++.h>
using namespace std;
int main() {
  long x, y;
  int n, num, cnt = 0, sum = 0;
  while (cin >> n && n != 0) {
    cnt = 0, sum = 0;
    bool a[4000] = {0};
    long p[4000] = {0};
    for (int i = 0; i < n; i++) {
      cin >> num >> x >> y;
      if (a[num] == 0) cnt++;
      a[num] = 1, p[num] += x * y;
    }
    for (int i = 1; i <= 4000; i++) {
      if (a[i] == 1 && p[i] >= 1000000) {
        cout << i << endl;
      } else if (a[i] == 1) {
        sum++;
      }
      if (cnt == sum) {
        cout << "NA" << endl;
        break;
      }
    }
  }
  return 0;
}
