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