#include <bits/stdc++.h>
using namespace std;
struct p {
  string s;
  int x, y;
} a[100005];
int cmp(p a, p b) {
  if (a.x == b.x) {
    return a.y > b.y;
  } else {
    return a.x > b.x;
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i].s >> a[i].x >> a[i].y;
  }
  sort(a, a + n, cmp);
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j < n; j++) {
      if (a[j].x == i) {
        if (a[j + 2].x == i && a[j + 2].y == a[j + 1].y) {
          cout << "?" << endl;
          break;
        } else {
          cout << a[j].s << " " << a[j + 1].s << endl;
          ;
          break;
        }
      }
    }
  }
}
