#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, k, t, n, m, counter, region, marks, regions[10011] = {0};
  string A;
  scanf("%d %d", &n, &m);
  vector<pair<int, pair<int, string> > > schoolers;
  for (i = 0; i < n; i++) {
    cin >> A >> region >> marks;
    schoolers.push_back(make_pair(region, make_pair(marks, A)));
    regions[region]++;
  }
  sort(schoolers.begin(), schoolers.end());
  counter = 0;
  for (i = 1; i <= m; i++) {
    if (regions[i] == 2) {
      cout << schoolers[counter + regions[i] - 1].second.second << " "
           << schoolers[counter + regions[i] - 2].second.second << endl;
    } else {
      if (schoolers[counter + regions[i] - 2].second.first ==
          schoolers[counter + regions[i] - 3].second.first) {
        cout << "?" << endl;
      } else {
        cout << schoolers[counter + regions[i] - 1].second.second << " "
             << schoolers[counter + regions[i] - 2].second.second << endl;
      }
    }
    counter += regions[i];
  }
  return 0;
}
