#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m, a, b, u = 1;
  string s;
  cin >> n >> m;
  vector<pair<int, pair<int, string>>> vk;
  for (int i = 0; i < n; i++) {
    cin >> s >> a >> b;
    vk.push_back(make_pair(a, make_pair(b, s)));
  }
  sort(vk.begin(), vk.end());
  vk.push_back(make_pair(20000, make_pair(900, s)));
  for (int i = 1; i <= n; i++) {
    if (vk[i].first == vk[i - 1].first)
      u++;
    else {
      if (u <= 2 || vk[i - 2].second.first != vk[i - 3].second.first)
        cout << vk[i - 1].second.second << " " << vk[i - 2].second.second
             << endl;
      else
        cout << '?' << endl;
      u = 1;
    }
  }
  return 0;
}
