#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, len;
  cin >> n >> m;
  vector<pair<int, string> > v[m + 1];
  for (int i = 0; i < n; i++) {
    int score, place;
    string name;
    cin >> name >> place >> score;
    v[place].push_back(make_pair(score, name));
  }
  for (int i = 1; i <= m; i++) {
    sort(v[i].begin(), v[i].end());
    len = v[i].size();
    if (len > 2) {
      if (v[i][len - 2].first == v[i][len - 3].first)
        cout << "?" << endl;
      else
        cout << v[i][len - 1].second << " " << v[i][len - 2].second << endl;
    } else
      cout << v[i][len - 1].second << " " << v[i][len - 2].second << endl;
  }
  return 0;
}
