#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
??
#include <stdio.h>
#include <ctype.h>
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <fstream>
#include <sstream>
#include <queue>
#include <exception>
#include <cmath>
#include <numeric>
??
using namespace std;
typedef long long int lint;
??
bool AOJ0100() {
????????lint n, e, p, q;
????????cin >> n;
????????if (n == 0) return false;
??
????????lint* data = new lint[4001];
????????for (int i = 0; i <= 4000; i++) data[i] = 0;
??
????????for (lint i = 0; i < n; i++) {
????????????????cin >> e >> p >> q;
????????????????data[e] += p * q;
????????}
??
????????bool flag = false;
????????for (int i = 1; i <= 4000; i++) {
????????????????if (data[i] >= 1000000) {
????????????????????????flag = true;
????????????????????????cout << i << endl;
????????????????}
????????}
????????if (!flag) cout << "NA" << endl;
??
????????delete[] data;
????????return true;
}
??
int main()
{
????????while (AOJ0100()) {
????????}
????????return 0;
}