#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, region, score;
  map<int, priority_queue<pair<int, string>>> S;
  string name, name2;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> name >> region >> score;
    S[region].push(make_pair(score, name));
  }
  for (i = 1; i <= m; i++) {
    name = S[i].top().second;
    S[i].pop();
    name2 = S[i].top().second;
    score = S[i].top().first;
    S[i].pop();
    if (!S[i].empty() && S[i].top().first == score) {
      cout << "?" << endl;
    } else {
      cout << name << " " << name2 << endl;
    }
  }
  return 0;
}
