#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e3 + 5;
const long long mod = 1e9 + 7;
const long long p = 31;
void c_p_c() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
void solve() {
  long long n, m;
  cin >> n >> m;
  string s;
  long long reg, poi;
  std::vector<pair<long long, string>> v[m + 1];
  for (long long i = (0); i < (n); i++) {
    cin >> s >> reg >> poi;
    v[reg].push_back(make_pair(poi, s));
  }
  for (long long i = 1; i <= m; i++) sort((v[i]).begin(), (v[i]).end());
  for (long long i = 1; i <= m; i++) reverse((v[i]).begin(), (v[i]).end());
  for (long long i = 1; i <= m; i++) {
    auto it = v[i].begin();
    long long x, y, z;
    string temp, temp1;
    x = it->first;
    temp = it->second;
    it++;
    y = it->first;
    temp1 = it->second;
    if (v[i].size() > 2) {
      it++;
      z = it->first;
      if (x >= y and y != z) {
        cout << temp << ' ' << temp1 << "\n";
      } else
        cout << "?\n";
    } else
      cout << temp << ' ' << temp1 << '\n';
  }
}
int32_t main() {
  c_p_c();
  solve();
}
