#include <bits/stdc++.h>
using namespace std;
bool mf(pair<string, int> a, pair<string, int> b) {
  return a.second > b.second;
}
int main() {
  int n, m;
  string surname;
  int rn;
  int ps;
  int min[10003];
  vector<pair<string, int>> team[10003];
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    cin >> surname;
    scanf("%d%d", &rn, &ps);
    if (ps >= min[rn] || team[rn].size() < 3) {
      team[rn].push_back(pair<string, int>(surname, ps));
      if (team[rn].size() == 4)
        team[rn].erase(max_element(team[rn].begin(), team[rn].end(), mf));
      min[rn] = max_element(team[rn].begin(), team[rn].end(), mf)->second;
    }
  }
  for (int i = 1; i <= m; ++i) {
    if (team[i].size() >= 2) {
      if (team[i].size() == 2) {
        cout << team[i][0].first << " " << team[i][1].first;
      } else {
        sort(team[i].begin(), team[i].end(), mf);
        if (team[i][1].second == team[i][2].second)
          printf("?");
        else
          cout << team[i][0].first << " " << team[i][1].first;
      }
    } else
      printf("?");
    if (i < m) printf("\n");
  }
  return 0;
}
