#include <bits/stdc++.h>
using namespace std;
int main() {
  int data[2][4000], n, i, f, id, a, b;
  while (1) {
    cin >> n;
    if (n == 0) break;
    for (i = 0; i < 4000; i++) data[0][i] = 0, data[1][i] = 0;
    for (i = 0; i < n; i++) {
      cin >> id >> a >> b;
      for (f = 0; f < i; f++) {
        if (data[0][f] == id) {
          data[1][f] += a * b, f = -1;
          break;
        }
      }
      if (f != -1) data[0][i] = id;
      data[1][i] = a * b;
    }
    for (i = 0, f = 0; i < n; i++)
      if (data[1][i] > 999999) cout << data[0][i] << "\n", f = 1;
    if (f == 0)
      cout << "NA"
           << "\n";
  }
}
