#include <bits/stdc++.h>
using namespace std;
void fre() {
  freopen("c://test//input.in", "r", stdin);
  freopen("c://test//output.out", "w", stdout);
}
template <class T1, class T2>
inline void gmax(T1 &a, T2 b) {
  if (b > a) a = b;
}
template <class T1, class T2>
inline void gmin(T1 &a, T2 b) {
  if (b < a) a = b;
}
const int N = 1e5 + 10, M = 1e4 + 10, Z = 1e9 + 7, ms63 = 0x3f3f3f3f;
int n, m;
char s[N][12];
vector<pair<int, int> > b[N];
int main() {
  while (~scanf("%d%d", &n, &m)) {
    for (int i = 1; i <= m; ++i) b[i].clear();
    for (int i = 1; i <= n; ++i) {
      int d, v;
      scanf("%s %d %d", s[i], &d, &v);
      b[d].push_back(make_pair(-v, i));
    }
    for (int i = 1; i <= m; ++i) {
      sort(b[i].begin(), b[i].end());
      if (b[i].size() == 2)
        printf("%s %s\n", s[b[i][0].second], s[b[i][1].second]);
      else if (b[i][1].first == b[i][2].first)
        puts("?");
      else
        printf("%s %s\n", s[b[i][0].second], s[b[i][1].second]);
    }
  }
  return 0;
}
