#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m[4001] = {};
  int num, coin, sell;
  int member[4001] = {}, j, p;
  while (1) {
    cin >> n;
    if (n == 0) break;
    p = 0;
    for (int i = 0; i < n; i++) {
      cin >> num >> coin >> sell;
      m[num] += coin * sell;
      for (j = 0; j < n; j++) {
        if (member[j] == num) break;
      }
      if (j == n) {
        member[p] = num;
        p++;
      }
    }
    j = 0;
    for (int i = 0; i < p; i++) {
      if (m[member[i]] >= 1000000)
        cout << member[i] << endl;
      else
        j++;
    }
    if (j == p) cout << "NA" << endl;
    for (int i = 0; i <= 4000; i++) {
      m[i] = 0;
      member[i] = 0;
    }
  }
  return 0;
}
