#include <bits/stdc++.h>
using namespace std;
int n;
int m;
multimap<int, int> a[100008];
multimap<int, int>::reverse_iterator it;
multiset<pair<int, string> > myset[100008];
multiset<pair<int, string> >::reverse_iterator itt;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cerr.tie(NULL);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    string s;
    int u;
    int sc;
    cin >> s >> u >> sc;
    u--;
    a[u].insert(pair<int, int>(sc, 0));
    myset[u].insert(pair<int, string>(sc, s));
  }
  for (int i = 0; i < m; i++) {
    it = a[i].rbegin();
    int rep = a[i].count(it->first);
    if (rep > 2) {
      cout << '?' << endl;
      continue;
    } else if (rep == 2) {
      itt = myset[i].rbegin();
      cout << itt->second << ' ';
      itt++;
      cout << itt->second;
      cout << endl;
    } else if (rep == 1) {
      it++;
      rep = a[i].count(it->first);
      if (rep >= 2) {
        cout << '?' << endl;
        continue;
      } else if (rep == 1) {
        itt = myset[i].rbegin();
        cout << itt->second << ' ';
        itt++;
        cout << itt->second;
        cout << endl;
      }
    }
  }
}
