#include <bits/stdc++.h>
using namespace std;
bool sort1(const pair<long long, string> &a, const pair<long long, string> &b) {
  return (a.first > b.first);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m;
  cin >> n >> m;
  vector<pair<long long, string> > v[m + 1];
  while (n--) {
    string s;
    cin >> s;
    long long r;
    cin >> r;
    long long p;
    cin >> p;
    v[r].push_back({p, s});
  }
  for (long long x = 1; x <= m; x++) {
    sort(v[x].begin(), v[x].end(), sort1);
  }
  for (long long x = 1; x <= m; x++) {
    long long m1 = v[x][0].first;
    long long nm1 = 1, nm2 = 0, m2;
    for (long long y = 1; y < v[x].size(); y++) {
      if (v[x][y].first == m1) {
        nm1++;
      } else {
        m2 = v[x][y].first;
        break;
      }
    }
    for (long long y = 1; y < v[x].size(); y++) {
      if (v[x][y].first == m2) {
        nm2++;
      } else {
        break;
      }
    }
    if (nm1 == 2) {
      cout << v[x][0].second << " " << v[x][1].second << "\n";
    } else {
      if (nm1 == 1 && nm2 == 1) {
        cout << v[x][0].second << " " << v[x][1].second << "\n";
      } else {
        cout << "?"
             << "\n";
      }
    }
  }
  return 0;
}
