#include <bits/stdc++.h>
using namespace std;
struct data {
  string name;
  int score;
  friend bool operator<(data a, data b) {
    if (a.score != b.score) return a.score > b.score;
    return a.name < b.name;
  }
};
int n, m;
vector<data> V[10000 + 2];
int main() {
  string name;
  int op, score;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    cin >> name;
    scanf("%d%d", &op, &score);
    V[op].push_back((data){name, score});
  }
  for (int i = 1; i <= m; ++i) {
    sort(V[i].begin(), V[i].end());
    if (V[i].size() < 2)
      printf("?\n");
    else if (V[i].size() == 2)
      printf("%s %s\n", V[i][0].name.c_str(), V[i][1].name.c_str());
    else if ((V[i][2].score == V[i][1].score))
      printf("?\n");
    else
      printf("%s %s\n", V[i][0].name.c_str(), V[i][1].name.c_str());
  }
  return 0;
}
