#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  map<int, set<pair<int, string>, greater<pair<int, string> > > > mp;
  for (int i = 0; i < n; i++) {
    string s;
    int a, b;
    cin >> s >> a >> b;
    mp[a].insert(pair<int, string>(b, s));
  }
  for (int i = 1; i <= m; i++) {
    pair<int, string> a, b, c;
    auto it = mp[i].begin();
    a = *it;
    it++;
    b = *it;
    if (mp[i].size() > 2)
      it++;
    else {
      cout << a.second << " " << b.second << endl;
      continue;
    }
    c = *it;
    if ((b.first == c.first)) {
      cout << "?" << endl;
    } else {
      cout << a.second << " " << b.second << endl;
    }
  }
  return 0;
}
