#include <bits/stdc++.h>
using namespace std;
struct StuNode {
  string name;
  int score;
};
vector<StuNode> stu[20005];
bool cmp(struct StuNode s1, struct StuNode s2) { return (s1.score > s2.score); }
int n, m;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    StuNode node;
    int region;
    cin >> node.name >> region >> node.score;
    stu[region].push_back(node);
  }
  for (int i = 1; i <= m; i++) {
    int nowsize = stu[i].size();
    sort(stu[i].begin(), stu[i].end(), cmp);
    if (nowsize == 2) {
      cout << stu[i][0].name << " " << stu[i][1].name << endl;
      continue;
    }
    string first, second;
    if (stu[i][0].score == stu[i][1].score) {
      if (stu[i][1].score == stu[i][2].score) {
        cout << "?" << endl;
      } else {
        cout << stu[i][0].name << " " << stu[i][1].name << endl;
      }
    } else {
      first = stu[i][0].name;
      if (stu[i][1].score == stu[i][2].score) {
        cout << "?" << endl;
      } else {
        second = stu[i][1].name;
        cout << first << " " << second << endl;
      }
    }
  }
}
