#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  map<int, vector<pair<int, string>>> pers;
  for (int a0 = 0; a0 < n; ++a0) {
    int r, p;
    string name;
    cin >> name >> r >> p;
    pers[r].push_back(pair<int, string>(p, name));
  }
  for (int i = 1; i <= m; ++i) {
    vector<pair<int, string>> k = pers[i];
    int len = k.size();
    sort(k.begin(), k.end());
    reverse(k.begin(), k.end());
    if (len > 2 && k[1].first == k[2].first)
      cout << "?"
           << "\n";
    else
      cout << k[0].second << " " << k[1].second << "\n";
  }
  return 0;
}
