#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int INF = 1000000000;
const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
const int N = 100001;
vector<pair<int, string> > a[10001];
int main() {
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; (i) < (n); ++i) {
    string name;
    int region;
    int ball;
    cin >> name >> region >> ball;
    a[region].push_back(make_pair(ball, name));
    sort((a[region]).begin(), (a[region]).end());
    reverse((a[region]).begin(), (a[region]).end());
    if (a[region].size() > 3) {
      a[region].pop_back();
    }
  }
  for (int i = 1; i <= m; i++) {
    if (a[i].size() == 2 && a[i][0].first >= a[i][1].first) {
      cout << a[i][0].second << " " << a[i][1].second << endl;
    } else if (a[i].size() == 3 && a[i][0].first > a[i][1].first &&
               a[i][1].first > a[i][2].first) {
      cout << a[i][0].second << " " << a[i][1].second << endl;
    } else if (a[i].size() == 3 && a[i][0].first >= a[i][1].first &&
               a[i][1].first > a[i][2].first) {
      cout << a[i][0].second << " " << a[i][1].second << endl;
    } else {
      cout << "?\n";
    }
  }
  return 0;
}
