#include <bits/stdc++.h>
using namespace std;
int main() {
  int data[2][10000], n, i, f, id, a, b;
  while (1) {
    cin >> n;
    if (n == 0) break;
    for (i = 0; i < 10000; i++) data[0][i] = 0, data[1][i] = 0;
    for (i = 0; i < n; i++) {
      cin >> id >> a >> b;
      for (f = 0; f < i + 1; f++) {
        if (data[0][f] == id) {
          data[1][f] += a * b, f = -1;
          break;
        } else if (data[0][f] == 0) {
          data[0][f] = id;
          data[1][f] = 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";
  }
}
