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