#include <bits/stdc++.h>
int main(void) {
  int i, set;
  int staffSales[4000];
  int passStaff[4000];
  int staff, price, sales;
  int PriSal, preStaSal;
  for (;;) {
    scanf("%d", &set);
    if (!set) break;
    for (i = 0; i < 4000; i++) {
      staffSales[i] = 0;
      passStaff[i] = 0;
    }
    for (i = 0; i < set; i++) {
      scanf("%d%d%d", &staff, &price, &sales);
      PriSal = price * sales;
      if (PriSal / price != sales) passStaff[staff] = 1;
      preStaSal = staffSales[staff];
      staffSales[staff] += PriSal;
      if (staffSales[staff] - PriSal != preStaSal) passStaff[staff] = 1;
      if (1000000 <= staffSales[staff]) passStaff[staff] = 1;
    }
    for (i = 0; i < 4000; i++)
      if (passStaff[i]) printf("%d\n", i);
  }
  return 0;
}
