#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
const long long N = 2e6 + 5;
const long long INF = 1e18L;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << ": " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
long long ar[N];
long long dp[N];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long T = 1;
  while (T--) {
    long long n, m;
    cin >> n >> m;
    vector<pair<long long, string>> v[m];
    for (long long i = 0; i < n; i++) {
      string s;
      long long t, sc;
      cin >> s >> t >> sc;
      --t;
      v[t].push_back({-sc, s});
    }
    for (long long j = 0; j < m; j++) {
      sort(v[j].begin(), v[j].end());
      if (v[j].size() == 2) {
        cout << v[j][0].second << " " << v[j][1].second << '\n';
      } else {
        if (v[j][1].first == v[j][2].first || v[j].size() < 2) {
          cout << "?\n";
        } else {
          cout << v[j][0].second << " " << v[j][1].second << '\n';
        }
      }
    }
  }
  return 0;
}
