#include <bits/stdc++.h>
using namespace std;
struct {
  int sum;
  bool flg;
} p[4000];
int main() {
  int a, b, c, n, i;
  while (cin >> n && n) {
    int m = 0;
    for (i = 0; i < 4000; i++) p[i].sum = 0, p[i].flg = false;
    for (i = 0; i < n; i++) {
      cin >> a >> b >> c;
      p[a - 1].sum += b * c;
    }
    for (i = 0; i < 4000; i++) {
      if (p[i].sum >= 1000000) {
        p[i].flg = true;
        m++;
      }
    }
    if (m <= 0)
      cout << "NA" << endl;
    else
      for (i = 0; i < 4000; i++)
        if (p[i].flg) cout << i + 1 << endl;
  }
}
