#include <bits/stdc++.h>
using namespace std;
struct st {
  string s;
  int score;
  bool operator<(const st& p) const { return score > p.score; }
};
vector<st> v[10001];
int main() {
  int n, m;
  st get;
  string s;
  int a, b;
  cin >> n >> m;
  while (n--) {
    cin >> s >> a >> b;
    get.s = s;
    get.score = b;
    v[a].push_back(get);
  }
  for (int i = 1; i <= m; i++) sort(v[i].begin(), v[i].end());
  for (int i = 1; i <= m; i++) {
    if (v[i].size() == 2)
      cout << v[i][0].s << " " << v[i][1].s;
    else if (v[i][1].score != v[i][2].score)
      cout << v[i][0].s << " " << v[i][1].s;
    else
      cout << "?";
    cout << endl;
  }
  return 0;
}
