#include <bits/stdc++.h>
using namespace std;
int vis[100005];
struct node {
  char st[15];
  int id;
  int value;
} a[100005];
int cmp(node a, node b) {
  if (a.id == b.id) return a.value > b.value;
  return a.id < b.id;
}
int main() {
  int n, m, l = 0;
  memset(vis, 0, sizeof(vis));
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    scanf("%s%d%d", a[i].st, &a[i].id, &a[i].value);
    vis[a[i].id]++;
  }
  sort(a, a + n, cmp);
  for (int i = 1; i <= m; i++) {
    if (vis[i] < 2) {
      printf("?\n");
      l += vis[i];
      continue;
    } else if (vis[i] >= 3) {
      if (a[l + 1].value == a[l + 2].value)
        printf("?\n");
      else
        printf("%s %s\n", a[l].st, a[l + 1].st);
      l += vis[i];
      continue;
    } else {
      printf("%s %s\n", a[l].st, a[l + 1].st);
      l += vis[i];
    }
  }
  return 0;
}
