#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
struct data {
  int points;
  string name;
  data(int p, string n) {
    points = p;
    name = n;
  }
  data() {
    points = -1;
    name = "";
  }
};
inline bool cmp(data d1, data d2) { return (d1.points > d2.points); }
int main() {
  int n, m, r, points;
  cin >> n >> m;
  string name;
  vector<vector<data>> reg(m);
  for (auto i(0); i < n; ++i) {
    cin >> name >> r >> points;
    r--;
    if (reg[r].size() < 3) {
      reg[r].push_back(data(points, name));
      sort(reg[r].begin(), reg[r].end(), cmp);
    } else {
      reg[r].push_back(data(points, name));
      sort(reg[r].begin(), reg[r].end(), cmp);
      reg[r].resize(3);
    }
  }
  for (auto i(0); i < m; ++i) {
    if (reg[i].size() == 2) {
      cout << reg[i][0].name << ' ' << reg[i][1].name << endl;
      ;
    } else if (reg[i][1].points == reg[i][2].points) {
      cout << '?' << endl;
    } else {
      cout << reg[i][0].name << ' ' << reg[i][1].name << endl;
    }
  }
  return 0;
}
