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