#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<int, string> > > v;
string s;
int p, pts;
bool cmp(pair<int, string> &a, pair<int, string> &b) {
  return a.first > b.first;
}
int main() {
  int n, m;
  cin >> n >> m;
  v.assign(m, vector<pair<int, string> >());
  for (int i = 0; i < n; ++i) {
    cin >> s >> p >> pts;
    v[p - 1].push_back(make_pair(pts, s));
  }
  for (int i = 0; i < m; ++i) {
    if (v[i].size()) sort(v[i].begin(), v[i].end(), cmp);
  }
  for (int i = 0; i < m; ++i) {
    if (v[i].size() >= 3 && (v[i][1].first == v[i][2].first))
      cout << "?\n";
    else
      cout << v[i][0].second << ' ' << v[i][1].second << '\n';
  }
}
