#include <bits/stdc++.h>
using namespace std;
const double PI = 3.1415926536;
struct person {
  string name;
  int score;
  person(string s, int x) {
    name = s;
    score = x;
  }
};
bool mysort(const person a, const person b) { return a.score > b.score; }
vector<vector<person> > v;
int main() {
  int n, m;
  cin >> n >> m;
  v.resize(m + 4);
  for (int i = 0; i < n; i++) {
    string s;
    int a, b;
    cin >> s >> a >> b;
    v[a].push_back(person(s, b));
  }
  for (int i = 1; i <= m; i++) {
    sort(v[i].begin(), v[i].end(), mysort);
    if (v[i].size() > 2 && v[i][1].score == v[i][2].score)
      cout << "?\n";
    else
      cout << v[i][0].name << " " << v[i][1].name << "\n";
  }
  return 0;
}
