#include <bits/stdc++.h>
using namespace std;
long long mod(long long a, long long b) {
  return a >= 0 ? a % b : (b + a % b) % b;
}
long long dceil(long long a, long long b) { return (a + b - 1) / b; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  priority_queue<pair<int, string>> q[10000];
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    int reg, score;
    cin >> reg >> score;
    reg--;
    q[reg].push({score, s});
  }
  for (int i = 0; i < m; i++) {
    string first = q[i].top().second;
    q[i].pop();
    string second = q[i].top().second;
    int score = q[i].top().first;
    q[i].pop();
    if (!q[i].empty() && q[i].top().first == score)
      cout << "?\n";
    else
      cout << first << " " << second << "\n";
  }
  return 0;
}
