#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  while (cin >> n, n != 0) {
    int data[4000];
    memset(data, -1, sizeof(data));
    for (int r = 0; r < n; r++) {
      int no, tanka, quantity;
      cin >> no >> tanka >> quantity;
      if (data[no] != -1) {
        data[no] += tanka * quantity;
      } else {
        data[no] = tanka * quantity;
      }
    }
    bool update = false;
    for (int r = 0; r < 4000; r++) {
      if (data[r] >= 1000000) {
        cout << r << endl;
        update = true;
      }
    }
    if (!update) cout << "NA" << endl;
  }
  return (0);
}
