#include <bits/stdc++.h>
using namespace std;
const int INF = 999999999;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1},
          dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
inline bool is_uruu(int y) {
  return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));
}
inline bool inside(int y, int x, int H, int W) {
  return (y >= 0 && x >= 0 && y < H && x < W);
}
bool same(vector<pair<int, long long> >& t, int num, long long p) {
  bool ok = true;
  for (int i = 0; i < (t.size()); i++) {
    if (num == t[i].first) {
      ok = false;
      t[i].second += p;
      break;
    }
  }
  return ok;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  while (cin >> n, n) {
    vector<pair<int, long long> > table;
    for (int i = 0; i < (n); i++) {
      bool ok = true;
      int num, price, cnt;
      cin >> num >> price >> cnt;
      if (same(table, num, price * cnt)) {
        table.push_back(make_pair(num, price * cnt));
      }
    }
    bool only = true;
    for (int i = 0; i < (table.size()); i++) {
      if (table[i].second >= 1e6) {
        cout << table[i].first << '\n';
        only = false;
      }
    }
    if (only) cout << "NA" << '\n';
  }
  return (0);
}
