#include <bits/stdc++.h>
using namespace std;
struct Node {
  string name;
  int score;
} M[10010][3];
int main() {
  Node tmp;
  int n, m, t;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> tmp.name >> t >> tmp.score;
    if (M[t][2].score <= tmp.score) swap(M[t][2], tmp);
    if (M[t][1].score <= M[t][2].score) swap(M[t][1], M[t][2]);
    if (M[t][0].score <= M[t][1].score) swap(M[t][0], M[t][1]);
  }
  for (int i = 1; i <= m; i++) {
    if (M[i][1].score == M[i][2].score && M[i][2].name != "")
      cout << "?" << endl;
    else
      cout << M[i][0].name << " " << M[i][1].name << endl;
  }
  return 0;
}
