#include <bits/stdc++.h>
using namespace std;
int n, m;
inline int read() {
  int t = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') f = (ch == '-') ? -1 : f, ch = getchar();
  while (ch >= '0' && ch <= '9') t = t * 10 + ch - '0', ch = getchar();
  return t * f;
}
struct orz {
  char s[16];
  int x, y;
  void in() { scanf("%s", s), x = read(), y = read(); }
  friend bool operator<(orz a, orz b) {
    return (a.x == b.x) ? a.y > b.y : a.x < b.x;
  }
} a[200105];
int main() {
  n = read(), m = read();
  for (register int i = 1; i <= n; i++) a[i].in();
  sort(a + 1, a + n + 1);
  int now = 1;
  for (register int i = 1; i <= m; i++) {
    while (a[now].x != i) now++;
    if (now + 2 <= n && a[now + 2].x == a[now + 1].x &&
        a[now + 2].y == a[now + 1].y)
      puts("?");
    else
      printf("%s %s\n", a[now].s, a[now + 1].s);
    now++;
  }
  return 0;
}
