#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, string> > v[111100];
  string second;
  int tp, mr;
  for (int i = 0; i < n; i++) {
    cin >> second >> tp >> mr;
    v[tp].push_back({mr, second});
  }
  for (int i = 1; i <= m; i++) {
    sort(v[i].begin(), v[i].end());
    reverse(v[i].begin(), v[i].end());
  }
  for (int i = 1; i <= m; i++) {
    if (v[i].size() == 2) {
      cout << v[i][0].second << " " << v[i][1].second << endl;
      continue;
    }
    if (v[i][1].first == v[i][2].first and v[i].size() > 1) {
      cout << "?" << endl;
    } else {
      cout << v[i][0].second << " " << v[i][1].second << endl;
    }
  }
}
