#include <bits/stdc++.h>
using namespace std;
int main() {
  while (1) {
    int n;
    cin >> n;
    if (!n) break;
    map<int, long long> a;
    for (int i = 0; i < n; i++) {
      long num, b, c;
      cin >> num >> b >> c;
      a[num] += (long long)b * c;
    }
    map<int, long long>::iterator p;
    bool flag = false;
    for (p = a.begin(); p != a.end(); p++)
      if (p->second >= 1000000) {
        cout << p->first << endl;
        flag = true;
      }
    if (flag == false) cout << "NA" << endl;
  }
}
