#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  string p;
  int r, s;
  vector<vector<int> > score;
  vector<vector<string> > name;
  vector<int> row;
  vector<string> col;
  for (int i = 0; i < m; i++) {
    score.push_back(row);
    name.push_back(col);
  }
  for (int i = 0; i < n; i++) {
    cin >> p >> r >> s;
    score[r - 1].push_back(s);
    name[r - 1].push_back(p);
  }
  for (int i = 0; i < m; i++) {
    int cnt[801];
    for (int j = 0; j < 801; j++) cnt[j] = 0;
    set<int> l;
    set<int>::iterator it;
    vector<int> ll;
    for (int k = score[i].size() - 1; k >= 0; k--) {
      l.insert(score[i][k]);
      cnt[score[i][k]]++;
    }
    for (it = l.begin(); it != l.end(); ++it) {
      ll.push_back(*it);
    }
    sort(ll.begin(), ll.end());
    if (!(cnt[ll[ll.size() - 1]] == 2) &&
        !(cnt[ll[ll.size() - 1]] == 1 && cnt[ll[ll.size() - 2]] == 1))
      cout << "?" << endl;
    else {
      if (cnt[ll[ll.size() - 1]] == 2) {
        int c = 0;
        for (int y = 0; y < score[i].size(); y++) {
          if (score[i][y] == ll[ll.size() - 1]) {
            c++;
            if (c == 1)
              cout << name[i][y] << " ";
            else
              cout << name[i][y];
          }
        }
        cout << endl;
      } else {
        int index1 = find(score[i].begin(), score[i].end(), ll[ll.size() - 1]) -
                     score[i].begin();
        int index2 = find(score[i].begin(), score[i].end(), ll[ll.size() - 2]) -
                     score[i].begin();
        cout << name[i][index1] << " " << name[i][index2] << endl;
      }
    }
  }
}
