#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<int, string> > > regions;
int main() {
  int n, m;
  cin >> n >> m;
  regions.resize(m);
  string name;
  int r, s;
  for (int i = 0; i < n; ++i) {
    cin >> name >> r >> s;
    regions[r - 1].push_back(make_pair(s, name));
  }
  for (int i = 0; i < m; ++i) {
    sort(regions[i].rbegin(), regions[i].rend());
    if (regions[i].size() == 2 || regions[i][1].first > regions[i][2].first)
      cout << regions[i][0].second << " " << regions[i][1].second << endl;
    else
      cout << "?" << endl;
  }
}
