#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (scanf("%d", &n) && n != 0) {
    vector<int> sales(4000, 0);
    vector<int> log;
    long long int prc, mnt;
    int num;
    for (int i = 0; i < n; i++) {
      scanf("%d%d%d", &num, &prc, &mnt);
      if (log.empty() || find(log.begin(), log.end(), num) == log.end()) {
        log.push_back(num - 1);
      }
      sales[num - 1] += prc * mnt;
    }
    bool flag = true;
    for (int i = 0; i < log.size(); i++) {
      printf("%d ", sales[log[i]]);
      if (sales[log[i]] >= 1000000) {
        flag = false;
        printf("%d\n", log[i] + 1);
      }
    }
    if (flag) printf("NA\n");
  }
}
