#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long int array[n][3];
  int count = 0;
  cin >> n;
  if (n == 0) goto Exit;
  for (int i = 0; i < n; i++) {
    cin >> array[i][0] >> array[i][1] >> array[i][2];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 1; i + j < n; j++) {
      if (array[i][0] == array[i + j][0]) {
        array[i][1] += array[i + j][1];
        array[i][2] += array[i + j][2];
        array[i + j][1] = 0;
        array[i + j][2] = 0;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (array[i][1] * array[i][2] >= 1000000) {
      cout << array[i][0] << "\n";
      count++;
    }
  }
Exit:;
  if (count == 0) {
    cout << "NA\n";
  }
}
