#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n, m;
  cin >> n >> m;
  vector<vector<pair<long long, string>>> v(m + 1);
  for (long long i = 0; i < n; i++) {
    string s;
    long long t, sc;
    cin >> s >> t >> sc;
    v[t].push_back({sc, s});
  }
  for (long long i = 1; i <= m; i++) {
    sort(v[i].rbegin(), v[i].rend());
    if (v[i].size() == 2)
      cout << v[i][0].second << " " << v[i][1].second << endl;
    else {
      if (v[i][1].first == v[i][2].first)
        cout << "?" << endl;
      else
        cout << v[i][0].second << " " << v[i][1].second << endl;
    }
  }
}
