#include <bits/stdc++.h>
using namespace std;
void answer() {
  long long int n, r;
  cin >> n >> r;
  string name;
  long long int region, score;
  vector<pair<int, string>> v[r];
  for (int i = 0; i < n; i++) {
    cin >> name >> region >> score;
    region--;
    v[region].push_back({score, name});
  }
  for (int i = 0; i < r; i++) {
    sort(v[i].begin(), v[i].end());
    reverse(v[i].begin(), v[i].end());
    auto& query = v[i];
    if (query.size() == 2 || query[2].first < query[1].first) {
      cout << query[0].second << " " << query[1].second << "\n";
    } else {
      cout << "?"
           << "\n";
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  while (t--) answer();
}
