#include <bits/stdc++.h>
using namespace std;
const int N = 10010;
set<pair<int, string> > s[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  for (int i = (int)0; i < (int)n; i++) {
    string name;
    int re, score;
    cin >> name >> re >> score;
    s[re].insert(make_pair(score, name));
  }
  for (int i = 1; i <= m; i++) {
    set<int> ss;
    set<pair<int, string> >::reverse_iterator it1 = s[i].rbegin(),
                                              it2 = s[i].rbegin(),
                                              it3 = s[i].rbegin();
    it2++;
    it3++;
    if ((int)(s[i].size()) == 2) {
      cout << (*it1).second << " " << (*it2).second << endl;
      continue;
    }
    it3++;
    if ((*it1).first == (*it2).first && (*it1).first == (*it3).first) {
      ;
      cout << "?" << endl;
    } else if ((*it1).first != (*it2).first && (*it2).first == (*it3).first) {
      ;
      cout << "?" << endl;
    } else if ((*it1).first == (*it2).first && (*it2).first != (*it3).first) {
      ;
      cout << (*it1).second << " " << (*it2).second << endl;
    } else {
      ;
      cout << (*it1).second << " " << (*it2).second << endl;
    }
  }
  return 0;
}
