#include <bits/stdc++.h>
using namespace std;
struct Student {
  string name;
  int point;
  Student(string& s, int p) : name(s), point(p) {}
};
bool operator<(const Student& s1, const Student& s2) {
  return s1.point > s2.point;
}
vector<Student> region[10001];
int main() {
  int n, m;
  int region_idx;
  cin >> n >> m;
  string name;
  int point;
  for (int i = 0; i < n; i++) {
    cin >> name;
    cin >> region_idx;
    cin >> point;
    region[region_idx].push_back(Student(name, point));
  }
  for (int i = 1; i <= m; i++) {
    sort(region[i].begin(), region[i].end());
    if (region[i].size() > 2 && region[i][1].point == region[i][2].point) {
      cout << "?" << endl;
    } else {
      cout << region[i][0].name << " " << region[i][1].name << endl;
    }
  }
  return 0;
}
