#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int M = 1e4 + 10;
int n, m;
pair<int, int> ball[M];
bool needmore[M];
int count[M];
pair<string, string> fam[M];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (int)1; i < (int)m + 1; ++i) ball[i] = make_pair(-1, -1);
  string tmp;
  int a, b;
  for (int i = (int)0; i < (int)n; ++i) {
    cin >> tmp >> a >> b;
    if (ball[a].first < b) {
      if (ball[a].first == ball[a].second)
        needmore[a] = 1;
      else
        needmore[a] = 0;
      ball[a].second = ball[a].first;
      ball[a].first = b;
      fam[a].second = fam[a].first;
      fam[a].first = tmp;
    } else if (ball[a].second < b) {
      ball[a].second = b;
      fam[a].second = tmp;
      needmore[a] = 0;
    } else if (ball[a].second == b) {
      needmore[a] = 1;
    }
  }
  for (int i = (int)1; i < (int)m + 1; ++i)
    if (needmore[i])
      printf("?\n");
    else {
      cout << fam[i].first << ' ' << fam[i].second << endl;
    }
  return 0;
}
