#include <bits/stdc++.h>
using namespace std;
priority_queue<pair<int, string> > all[10010];
int main() {
  int n, m;
  cin >> n >> m;
  string name;
  int reg, sc;
  for (int i = 0; i < n; i++) {
    cin >> name >> reg >> sc;
    all[reg].push(make_pair(sc, name));
  }
  for (int i = 1; i <= m; i++) {
    int tt[4];
    int tool = 0;
    pair<int, string> p[4];
    while (all[i].size()) {
      p[tool] = all[i].top();
      all[i].pop();
      tt[tool++] = p[tool].first;
      if (tool == 3) break;
    }
    if (tool == 2) {
      cout << p[0].second << " " << p[1].second << endl;
    } else {
      if (p[0].first == p[2].first || p[1].first == p[2].first) {
        cout << "?" << endl;
      } else {
        cout << p[0].second << " " << p[1].second << endl;
      }
    }
  }
  return 0;
}
