#include <bits/stdc++.h>
#pragma warning(disable : 4996)
int main(void) {
  int n, i, p, q;
  int j;
  int ans[1000];
  int a = 0;
  scanf("%d", &n);
  while (n != 0) {
    for (j = 0; j < n; j++) {
      scanf("%d%d%d", &i, &p, &q);
      if (p * q >= 1000000) {
        ans[a] = i;
        a++;
      }
    }
    scanf("%d", &n);
  }
  for (j = 0; j < a; j++) {
    printf("%d\n", ans[j]);
  }
  return 0;
}
