#include <bits/stdc++.h>
using namespace std;
struct node {
  char name[20];
  int id;
  int num;
} a[100005];
bool cmp(node x, node y) {
  if (x.id == y.id) return x.num > y.num;
  return x.id < y.id;
}
int main() {
  int n, m;
  while (cin >> n >> m) {
    for (int i = 0; i < n; i++) {
      scanf(" %s %d %d", a[i].name, &a[i].id, &a[i].num);
    }
    sort(a, a + n, cmp);
    int st = 0, ed = 0;
    for (st = 0; st < n; st = ed) {
      while (ed < n && a[ed].id == a[st].id) ed++;
      int fir = a[st].num;
      int sec = a[st + 1].num;
      if (ed - st > 2 && sec == a[st + 2].num) {
        printf("?\n");
      } else {
        printf("%s %s\n", a[st].name, a[st + 1].name);
      }
    }
  }
  return 0;
}
