#include <bits/stdc++.h>
using namespace std;
pair<pair<int, int>, string> p[202020];
int cnt[20202];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> p[i].second >> p[i].first.first >> p[i].first.second;
    cnt[p[i].first.first]++;
  }
  sort(p, p + n);
  int pos = 0;
  for (int i = 1; i <= m; i++) {
    if (i != 1)
      pos += cnt[i];
    else
      pos = cnt[i] - 1;
    if (p[pos - 1].first.second == p[pos - 2].first.second && cnt[i] != 2)
      puts("?");
    else
      cout << p[pos].second << " " << p[pos - 1].second << endl;
  }
  return 0;
}
