#include <bits/stdc++.h>
using namespace std;
struct student {
  string name;
  int marks;
};
bool cmp(struct student A, struct student B) { return A.marks > B.marks; }
int main() {
  int n, m, r, p;
  student A;
  scanf("%d%d", &n, &m);
  vector<student> ss[m + 1];
  for (int i = 0; i < n; i++) {
    cin >> A.name >> r >> A.marks;
    ss[r].push_back(A);
  }
  for (int i = 1; i <= m; i++) {
    sort(ss[i].begin(), ss[i].end(), cmp);
    if (ss[i].size() == 2) {
      cout << ss[i][0].name << " " << ss[i][1].name << "\n";
    } else if (ss[i][0].marks >= ss[i][1].marks &&
               ss[i][1].marks > ss[i][2].marks) {
      cout << ss[i][0].name << " " << ss[i][1].name << "\n";
    } else
      cout << "?\n";
  }
  return 0;
}
