#include <bits/stdc++.h>
using namespace std;
struct Play {
  string name;
  int team;
  int val;
  bool operator<(const Play& rhs) const { return val > rhs.val; }
};
const int maxn = 100000 + 100;
Play a[maxn];
bool ok[maxn / 10];
vector<Play> res[maxn / 10];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i].name >> a[i].team >> a[i].val;
  }
  sort(a, a + n);
  memset(ok, 0, sizeof(ok));
  for (int i = 0; i < n; i++) {
    if (res[a[i].team].size() < 2) {
      res[a[i].team].push_back(a[i]);
    } else {
      if (res[a[i].team].back().val == a[i].val) {
        ok[a[i].team] = 1;
      }
    }
  }
  for (int i = 1; i <= m; i++) {
    if (ok[i]) {
      cout << "?\n";
    } else {
      cout << res[i][0].name << " " << res[i][1].name << "\n";
    }
  }
  return 0;
}
