#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
inline void minup(T1& m, T2 x) {
  if (m > x) m = static_cast<T2>(x);
}
template <class T1, class T2>
inline void maxup(T1& m, T2 x) {
  if (m < x) m = static_cast<T2>(x);
}
const int N = 4000;
int n;
long long int cost[N];
int id;
long long int dc, dn;
int main() {
  while ((cin >> n) && n) {
    bool flag = true;
    for (int(i) = 0; (i) < (N); (i)++) cost[i] = 0LL;
    for (int(i) = 0; (i) < (n); (i)++) {
      cin >> id >> dc >> dn;
      cost[id - 1] += dc * dn;
    }
    for (int(i) = 0; (i) < (N); (i)++)
      if (cost[i] >= 1000000) {
        flag = false;
        cout << i + 1 << endl;
      }
    if (flag) puts("NA");
  }
  return 0;
}
