#include <bits/stdc++.h>
using namespace std;
struct node {
  int x;
  string s;
  node() {}
  node(int _x, string _s) {
    x = _x;
    s = _s;
  }
  friend bool operator<(node a, node b) { return a.x < b.x; }
};
priority_queue<node> que[111111];
node a[111111][3];
int main() {
  int T;
  int n, m;
  string s;
  int x, id;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> s >> id >> x;
    que[id].push(node(x, s));
  }
  for (int i = 1; i < m + 1; i++) {
    int p = 0;
    while (!que[i].empty() && p < 3) {
      a[i][p++] = que[i].top();
      que[i].pop();
    }
    if (p == 2 || a[i][1].x != a[i][2].x) {
      cout << a[i][0].s << " " << a[i][1].s << endl;
    } else
      puts("?");
  }
  return 0;
}
