#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<map<int, vector<string> > > A(m + 1);
  for (int x = 0; x < n; x++) {
    string name;
    int r, points;
    cin >> name >> r >> points;
    A[r][points].push_back(name);
  }
  for (int x = 1; x <= m; x++) {
    vector<string> tmp;
    for (auto it = A[x].rbegin(); it != A[x].rend(); it++) {
      for (string s : it->second) tmp.push_back(s);
      if (tmp.size() >= 2) break;
    }
    if (tmp.size() > 2)
      cout << "?\n";
    else
      cout << tmp[0] << " " << tmp[1] << '\n';
  }
}
