#include <bits/stdc++.h>
using namespace std;
const long long N = (int)1e6 + 7;
const int INF = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
vector<vector<pair<int, string> > > v;
void solve() {
  int n, m;
  scanf("%d %d", &n, &m);
  v.resize(n + 1);
  for (int i = 1; i <= n; i++) {
    string s;
    int type, c;
    cin >> s >> type >> c;
    v[type].push_back(make_pair(c, s));
  }
  for (int i = 1; i <= m; i++) {
    if (v[i].size() == 2) {
      cout << v[i][0].second << ' ' << v[i][1].second << endl;
      continue;
    }
    sort(v[i].begin(), v[i].end());
    reverse(v[i].begin(), v[i].end());
    if (v[i][1].first != v[i][2].first) {
      cout << v[i][0].second << ' ' << v[i][1].second << endl;
    } else {
      cout << "?" << endl;
    }
  }
}
int main() {
  int test = 1;
  while (test--) {
    solve();
  }
}
