#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  int n, m, x, y;
  string s;
  cin >> n >> m;
  vector<pair<int, string> > v[m + 1];
  for (int i = 0; i < n; ++i) {
    cin >> s >> x >> y;
    v[x].push_back({y, s});
  }
  for (int i = 0; i < m; ++i) {
    sort(v[i + 1].begin(), v[i + 1].end());
  }
  for (int i = 1; i <= m; ++i) {
    int t = v[i].size();
    if (t == 2) {
      cout << v[i][0].second << " " << v[i][1].second << endl;
    } else if (v[i][t - 3].first != v[i][t - 2].first) {
      cout << v[i][t - 2].second << " " << v[i][t - 1].second << endl;
    } else
      cout << "?" << endl;
  }
  return 0;
}
