#include <bits/stdc++.h>
using namespace std;
vector<pair<int, string>> v[100005];
bool cmp(pair<int, string> a, pair<int, string> b) {
  if (a.first == b.first)
    return a.second > b.second;
  else
    return a.first > b.first;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) v[i].clear();
  for (int i = 1; i <= n; i++) {
    int id, score;
    string name;
    cin >> name >> id >> score;
    v[id].push_back(make_pair(score, name));
  }
  for (int i = 1; i <= m; i++) {
    sort(v[i].begin(), v[i].end(), cmp);
  }
  for (int i = 1; i <= m; i++) {
    if (v[i][0].first == v[i][1].first) {
      if (v[i].size() == 2 || v[i][1].first != v[i][2].first) {
        cout << v[i][0].second << " " << v[i][1].second << endl;
      } else
        printf("?\n");
    } else {
      if (v[i].size() == 2 || v[i][1].first != v[i][2].first) {
        cout << v[i][0].second << " " << v[i][1].second << endl;
      } else
        printf("?\n");
    }
  }
  return 0;
}
