#include <bits/stdc++.h>
using namespace std;
long long x[1000000], a, b, c, n;
int main() {
  while (1) {
    memset(x, 0, sizeof(x));
    cin >> n;
    if (!n) {
      break;
    }
    for (int i = 0; i < n; i++) {
      cin >> a >> b >> c;
      x[a] += b * c;
      if (x[a] >= 1000000) {
        cout << a << endl;
      }
    }
  }
}
