#include <bits/stdc++.h>
struct salesmen {
  int i;
  long int p;
  long int q;
};
int main() {
  int n = 1;
  while (n) {
    scanf("%d", &n);
    if (n == 0) break;
    struct salesmen man[n];
    struct salesmen *mp;
    mp = man;
    int j;
    for (j = 0; j < n; j++)
      scanf("%d %ld %ld", &(mp + j)->i, &(mp + j)->p, &(mp + j)->q);
    mp = man;
    long long int total;
    for (j = 0; j < n; j++) {
      total = (mp + j)->p * (mp + j)->q;
      if (total >= 1000000) printf("%d", (mp + j)->i);
    }
  }
  return 0;
}
