#include <bits/stdc++.h>
using namespace std;
const int SIZE = 1e+5 + 1;
const int INF = 1 << 30;
const long double eps = 1e-6;
const long long mod = 1e+9 + 7;
int main() {
  int n;
  while (cin >> n && n) {
    bool check[4096] = {0};
    long long sum[4096] = {0};
    vector<int> data;
    for (int i = (0); i < (n); i++) {
      int id, money, num;
      scanf("%d%d%d", &id, &money, &num);
      if (!check[id]) {
        check[id] = true;
        data.push_back(id);
      }
      sum[id] += money * num;
    }
    bool ok = false;
    for (int i = (0); i < (data.size()); i++) {
      if (sum[data[i]] >= 1000000) {
        printf("%d\n", data[i]);
        ok = true;
      }
    }
    if (!ok) cout << "NA" << endl;
  }
  return 0;
}
