#include <bits/stdc++.h>
using namespace std;
long long data[4010];
bool out[4010];
int main() {
  int i, j, k, n;
  while (scanf("%d", &n)) {
    if (n == 0) break;
    long long a, b;
    int id;
    vector<int> ids;
    bool f = false;
    for ((i) = (0); (i) < (int)(4010); (i)++) data[i] = 0;
    for ((i) = (0); (i) < (int)(4010); (i)++) out[i] = false;
    while (n--) {
      scanf("%d %lld %lld", &id, &a, &b);
      ids.push_back(id);
      data[id] += a * b;
      if (data[id] >= 1000000LL) out[id] = true;
    }
    for ((i) = (0); (i) < (int)(ids.size()); (i)++)
      if (out[ids[i]]) {
        printf("%d\n", ids[i]);
        out[ids[i]] = false;
        f = true;
      }
    if (f) puts("NO");
  }
  return 0;
}
