#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 10;
const int md = 1e9 + 7;
const double EPS = 1e-6;
struct player {
  string name;
  int score;
  player(string _name, int _score) {
    name = _name;
    score = _score;
  }
};
vector<player> g[10010];
bool cmp(player x, player y) { return x.score > y.score; }
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    string name;
    int number, score;
    cin >> name >> number >> score;
    g[number].push_back(player(name, score));
  }
  for (int i = 1; i <= m; i++) {
    sort(g[i].begin(), g[i].end(), cmp);
    if (g[i].size() > 2 && g[i][1].score == g[i][2].score)
      cout << "?\n";
    else
      cout << g[i][0].name << " " << g[i][1].name << "\n";
  }
}
