#include <bits/stdc++.h>
using namespace std;
vector<pair<int, string>> adj[100005];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    string name;
    int distict, score;
    cin >> name >> distict >> score;
    adj[distict].push_back({score, name});
  }
  for (int i = 1; i <= m; i++) sort(adj[i].rbegin(), adj[i].rend());
  for (int i = 1; i <= m; i++) {
    int c = 0;
    bool flag = 0;
    int score1 = adj[i][0].first, score2 = adj[i][1].first;
    for (int j = 0; j < (int)adj[i].size(); j++) {
      if (adj[i][j].first == score1 or adj[i][j].first == score2)
        c++;
      else
        break;
      if (c > 2) {
        flag = 1;
        break;
      }
    }
    if (flag) {
      cout << '?' << "\n";
      ;
    } else
      cout << adj[i][0].second << ' ' << adj[i][1].second << "\n";
    ;
  }
}
