#include <bits/stdc++.h>
using namespace std;
vector<pair<int, string> > v[100005];
int n, m;
bool cmp(const pair<int, string>& a, const pair<int, string>& b) {
  if (a.first == b.first)
    return a.second > b.second;
  else
    return a.first > b.first;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) v[i].clear();
  for (int i = 1; i <= n; i++) {
    int id, score;
    char name[20];
    scanf("%s%d%d", 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)
        printf("%s %s\n", v[i][0].second.c_str(), v[i][1].second.c_str());
      else
        puts("?");
      continue;
    }
    if (v[i].size() == 2 || v[i][1].first > v[i][2].first)
      printf("%s %s\n", v[i][0].second.c_str(), v[i][1].second.c_str());
    else
      puts("?");
  }
  return 0;
}
