#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, reg, score;
  string nome;
  cin >> n >> m;
  set<pair<int, string> > s[m + 1];
  set<pair<int, string> >::iterator it;
  for (int i = 0; i < n; i++) {
    getchar();
    cin >> nome >> reg >> score;
    s[reg].insert({score, nome});
  }
  for (int i = 1; i <= m; i++) {
    int vet[3];
    if (s[i].size() > 2) {
      it = s[i].end();
      it--;
      vet[0] = it->first;
      it--;
      vet[1] = it->first;
      it--;
      vet[2] = it->first;
      if (vet[1] == vet[2])
        cout << "?\n";
      else {
        it++;
        it++;
        cout << it->second;
        it--;
        cout << " " << it->second << endl;
      }
    } else if (s[i].size() < 2)
      cout << "?\n";
    else {
      it = s[i].end();
      it--;
      cout << it->second;
      it--;
      cout << " " << it->second << endl;
    }
  }
  return 0;
}
