#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  vector<string> parts(n);
  vector<vector<pair<long long, long long> > > players(m);
  for (long long i = 0; i < n; i++) {
    long long region, score;
    string name;
    cin >> name >> region >> score;
    parts[i] = name;
    players[region - 1].push_back(make_pair(score, i));
  }
  for (auto &x : players) {
    sort(x.rbegin(), x.rend());
  }
  for (long long i = 0; i < m; i++) {
    if (players[i].size() > 2 && players[i][1].first == players[i][2].first) {
      cout << "?" << endl;
    } else {
      cout << parts[players[i][0].second] << " " << parts[players[i][1].second]
           << endl;
    }
  }
  cin >> n;
  return 0;
}
