#include <bits/stdc++.h>
using namespace std;
int main() {
  int Line = 0, Temp;
  bool Exist;
  while (cin >> Line, Line) {
    double EmployObj[4001] = {0};
    double SellingPrice = 0, SalesVolume = 0;
    Exist = true;
    do {
      cin >> Temp >> SellingPrice >> SalesVolume;
      EmployObj[Temp] += SellingPrice * SalesVolume;
    } while (--Line);
    for (int count = 1; count <= 4001; count++) {
      if (EmployObj[count] >= 1000000) {
        cout << count << endl;
        Exist = false;
      }
    }
    if (Exist) {
      cout << "NA" << endl;
    }
  }
  return 0;
}
