#include <bits/stdc++.h>
using namespace std;
struct con {
  char name[30];
  int area;
  double level;
} num[100010];
bool cmp(con a, con b) {
  if (a.area != b.area)
    return a.area < b.area;
  else
    return a.level > b.level;
}
int main() {
  int n, m;
  while (cin >> n >> m) {
    for (int i = 0; i < n; i++)
      cin >> num[i].name >> num[i].area >> num[i].level;
    sort(num, num + n, cmp);
    int ans = 1;
    for (int i = 0; i < n; i++) {
      if (num[i].area == ans) {
        if ((num[i + 1].level != num[i + 2].level ||
             num[i + 1].area != num[i + 2].area) &&
            num[i].area == num[i + 1].area)
          cout << num[i].name << ' ' << num[i + 1].name << endl;
        else
          cout << '?' << endl;
        ans++;
      }
    }
  }
  return 0;
}
