#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  long long n, m;
  cin >> n >> m;
  vector<vector<pair<long long, string> > > v(m + 1);
  string x;
  long long y;
  long long z;
  for (long long i = 0; i < n; i++) {
    cin >> x >> y >> z;
    v[y].push_back(make_pair(z, x));
  }
  for (long long i = 1; i <= m; i++) {
    sort(v[i].rbegin(), v[i].rend());
    vector<pair<long long, string> > temp;
    int j = 0;
    for (vector<pair<long long, string> >::iterator it = v[i].begin();
         it != v[i].end() && j < 3; it++, j++) {
      temp.push_back(*it);
    }
    if (temp.size() == 2)
      cout << temp[0].second << " " << temp[1].second << "\n";
    else {
      if (temp[1].first == temp[2].first)
        cout << "?"
             << "\n";
      else
        cout << temp[0].second << " " << temp[1].second << "\n";
    }
  }
  return 0;
}
