#include <bits/stdc++.h>
using namespace std;
vector<pair<int, string> > v[10001];
int n, m;
int main() {
  string s;
  int r, p;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> s >> r >> p;
    v[r - 1].push_back(make_pair(-p, s));
  }
  for (int i = 0; i < m; i++) {
    s = "";
    sort(v[i].begin(), v[i].end());
    s += v[i][0].second + " ";
    if (v[i].size() == 2) {
      cout << s << v[i][1].second << endl;
      continue;
    }
    if (v[i][1].first == v[i][2].first) {
      cout << "?" << endl;
      continue;
    }
    cout << s << v[i][1].second << endl;
  }
  return 0;
}
