#include <bits/stdc++.h>
using namespace std;
unsigned long long data[4001];
int status;
void print() {
  for (int i = 0; i < 4001; i++)
    if (data[i] >= 1000000) {
      cout << i << endl;
      status = 0;
    }
}
int main() {
  unsigned long long in;
  while (cin >> in && in) {
    status = 1;
    fill(data, data + 4001, 0);
    for (int i = 0; i < in; i++) {
      unsigned long long num, p, q;
      cin >> num >> p >> q;
      data[num] += p * q;
    }
    print();
    if (status) cout << "NA" << endl;
  }
  return 0;
}
