#include <bits/stdc++.h>
using namespace std;
vector<pair<int, string> > vec[10000008];
int main() {
  int n, m;
  cin >> n >> m;
  set<int> s;
  string str;
  int num;
  int points;
  for (int i = 0; i < n; i++) {
    cin >> str >> num >> points;
    s.insert(num);
    vec[num].push_back(make_pair(points, str));
  }
  int mn = s.size();
  for (int i = 1; i <= mn; i++) {
    sort(vec[i].begin(), vec[i].end());
    reverse(vec[i].begin(), vec[i].end());
    int y = vec[i].size();
    if ((y == 2) || (y > 2 && vec[i][1].first != vec[i][2].first)) {
      string str1 = vec[i][0].second;
      string str2 = vec[i][1].second;
      cout << str1 << " " << str2 << endl;
    } else {
      cout << "?" << endl;
    }
  }
  return 0;
}
