#include <bits/stdc++.h>   using namespace std;   vector<pair<long long, string> > v[10020];   int main() {     long long n, m;     pair<long long, string> p;     long long temp;     cin >> n >> m;     for (int i = 0; i < n; i++) {       cin >> p.second;       cin >> temp;       cin >> p.first;       v[temp].push_back(p);     }     for (int i = 1; i <= m; i++) {       sort(v[i].begin(), v[i].end());     }     for (int i = 1; i <= m; i++) {       int k = v[i].size();       if (k < 2 || (k > 2 && v[i][k - 2].first == v[i][k - 3].first)) {         cout <<  ?  << endl;       } else {         cout << v[i][k - 1].second <<     << v[i][k - 2].second << endl;       }     }     return 0;   }   