#include <bits/stdc++.h>
using namespace std;
map<int, map<int, vector<string> > > mp;
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    string s;
    int a, b;
    cin >> s >> a >> b;
    mp[a][-b].push_back(s);
  }
  for (int i = 1; i <= m; i++) {
    map<int, vector<string> >::iterator it = mp[i].begin();
    if ((*it).second.size() > 2) {
      cout << "?" << endl;
    } else if ((*it).second.size() == 2) {
      cout << (*it).second[0] << " " << (*it).second[1] << endl;
    } else {
      string k = (*it).second[0];
      it++;
      if ((*it).second.size() == 1)
        cout << k << " " << (*it).second[0] << endl;
      else
        cout << "?" << endl;
    }
  }
  return 0;
}
