#include <bits/stdc++.h>
using namespace std;
int main() {
  int num, man, yen, ko;
  int ach;
  int c;
  int g[20][2] = {{}};
  int flag;
  while (1) {
    c = 0;
    flag = 1;
    cin >> num;
    if (!num) break;
    for (int i = 1; i <= num; i++) {
      int j = i;
      cin >> man >> yen >> ko;
      ach = yen * ko;
      for (; j > 1; j--) {
        if (g[j - 1][0] == man) {
          g[j - 1][1] += ach;
          flag--;
        }
        if (g[j - 1][1] >= 1000000) {
          cout << man << endl;
          c++;
        }
      }
      if (flag) {
        g[i][0] = man;
        g[i][1] = ach;
      }
      if (flag || g[i][1] >= 1000000) {
        cout << man << endl;
        c++;
      }
    }
    if (c == 0) cout << "NA" << endl;
  }
  return 0;
}
