#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
  return b <= 0 ? a : gcd(b, a % b);
}
template <class T>
T lcm(T a, T b) {
  return (a * b) / gcd(a, b);
}
template <class T>
T large(T a, T b) {
  return a > b ? a : b;
}
template <class T>
T small(T a, T b) {
  return a < b ? a : b;
}
template <class T>
T dif(T a, T b) {
  return a - b < 0 ? b - a : a - b;
}
template <class T>
string toStr(const T &x) {
  stringstream s;
  s << x;
  return s.str();
}
template <class T>
int toInt(const T &x) {
  stringstream s;
  s << x;
  int r;
  s >> r;
  return r;
}
void in() {}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  map<int, vector<pair<int, string> > > m1;
  map<int, string> m2;
  int n, m, a, b, i;
  string s;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> s >> a >> b;
    m1[a].push_back(make_pair(b, s));
  }
  for (i = 0; i < m1.size(); i++) {
    sort(m1[i].rbegin(), m1[i].rend());
  }
  for (auto it : m1) {
    for (i = 0; i < it.second.size(); i++) {
      if (it.second[1].first == it.second[2].first) {
        cout << "?" << endl;
        break;
      } else {
        if (i < 1)
          cout << it.second[i].second << " " << it.second[i + 1].second << endl;
      }
    }
  }
  return 0;
}
