#include <bits/stdc++.h>
int main() {
  int n;
  std::cin >> n;
  std::vector<int> A;
  while (n != 0) {
    std::vector<int> m(n);
    std::vector<std::vector<int>> V(n, std::vector<int>(3));
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < 3; ++j) {
        std::cin >> V[i][j];
      }
    }
    for (int i = 0; i < n; ++i) {
      m[i] = V[i][1] * V[i][2];
    }
    sort(V.begin(), V.end());
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; ++j) {
        if (i < j) {
          if (V[i][0] == V[j][0]) {
            m[i] += m[j];
            m[j] = 0;
          }
        }
      }
    }
    for (int i = 0; i < n; ++i) {
      if (m[i] >= 1000000) {
        A.push_back(V[i][0]);
      }
    }
    std::cin >> n;
  }
  return 0;
}
