#include <bits/stdc++.h>
using namespace std;
struct node {
  string name;
  int score;
};
const int maxn = 2 * (1e5) + 5;
node a[maxn];
vector<node> v[maxn];
int cmp(node x, node y) { return x.score > y.score; }
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < maxn; i++) v[i].clear();
  string name;
  int pos, score;
  for (int i = 0; i < n; i++) {
    cin >> name >> pos >> score;
    a[i].name = name;
    a[i].score = score;
    v[pos].push_back(a[i]);
  }
  for (int i = 1; i <= m; i++) {
    sort(v[i].begin(), v[i].end(), cmp);
    if (v[i].size() > 2 && v[i][1].score == v[i][2].score)
      cout << "?"
           << "\n";
    else
      cout << v[i][0].name << " " << v[i][1].name << "\n";
  }
  return 0;
}
