#include <bits/stdc++.h>
using namespace std;
int main() {
  while (1) {
    int sum = 0;
    int n;
    cin >> n;
    if (n == 0) break;
    queue<int> q;
    bool checked[4000];
    int list[4000];
    for (int i = 0; i < 4000; i++) {
      checked[i] = false;
      list[i] = 0;
    }
    for (int i = 0; i < n; i++) {
      int no, x, y;
      cin >> no >> x >> y;
      list[no] += x * y;
      if (!checked[no]) {
        q.push(no);
        checked[no] = true;
      }
    }
    if (q.empty()) cout << "NA" << endl;
    while (!q.empty()) {
      int no = q.front();
      q.pop();
      if (list[no] >= 1000000) cout << no << endl;
    }
  }
  return 0;
}
