#include <bits/stdc++.h>
using namespace std;
struct infmt {
  char name[15];
  int region;
  int score;
} a[100005];
bool cmp(infmt a, infmt b) {
  if (a.region == b.region)
    return a.score > b.score;
  else
    return a.region < b.region;
}
int main() {
  int m, n, i, j, k;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++)
    scanf("%s%d%d", &a[i].name, &a[i].region, &a[i].score);
  sort(a, a + n, cmp);
  int t = 1;
  for (i = 0; i < n; i++) {
    if (t == a[i].region) {
      if (i + 2 >= n || a[i + 2].region == t + 1 ||
          a[i + 2].score < a[i + 1].score)
        printf("%s %s\n", a[i].name, a[i + 1].name);
      else
        puts("?");
      t++;
    }
  }
  return 0;
}
