#include <bits/stdc++.h>
using namespace std;
int main() {
  int i;
  int n, m;
  cin >> n >> m;
  string s;
  int team;
  int result;
  int t[m + 1][3];
  string ans[m + 1][2];
  for (i = 1; i <= m; i++) {
    t[i][0] = -1;
    t[i][1] = -1;
    t[i][2] = -1;
  }
  for (i = 1; i <= n; i++) {
    cin >> s >> team >> result;
    if (t[team][0] <= result) {
      t[team][2] = t[team][1];
      ans[team][1] = ans[team][0];
      t[team][1] = t[team][0];
      ans[team][0] = s;
      t[team][0] = result;
    } else if (t[team][1] <= result) {
      t[team][2] = t[team][1];
      ans[team][1] = s;
      t[team][1] = result;
    } else if (t[team][2] <= result) {
      t[team][2] = result;
    }
  }
  for (i = 1; i <= m; i++) {
    if (t[i][1] == t[i][2]) {
      cout << "?\n";
    } else {
      cout << ans[i][0] << " " << ans[i][1] << "\n";
    }
  }
  return 0;
}
