#include <bits/stdc++.h>
using namespace std;
const int maxM = 10001;
int n, m, a, k;
string s;
vector<pair<int, string> > t[maxM];
bool comp(pair<int, string> a, pair<int, string> b) {
  return a.first > b.first;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> s >> a >> k;
    t[a].push_back(make_pair(k, s));
  }
  for (int i = 1; i <= m; i++) {
    sort(t[i].begin(), t[i].end(), comp);
  }
  for (int i = 1; i <= m; ++i) {
    if (t[i].size() == 2) {
      cout << t[i][0].second << " " << t[i][1].second;
    } else if (t[i].size() > 2 && t[i][1].first != t[i][2].first) {
      cout << t[i][0].second << " " << t[i][1].second;
    } else if (t[i].size() > 2 && t[i][1].first == t[i][2].first) {
      cout << "?";
    } else
      continue;
    if (i != m) cout << endl;
  }
  return 0;
}
