#include <bits/stdc++.h>
using namespace std;
struct st {
  st(string* name, int region, int rate)
      : name(name), region(region), rate(rate) {}
  string* name;
  int region;
  int rate;
};
st* a[100005];
bool cmp(st* i, st* j) {
  if (i->region == j->region) {
    return i->rate < j->rate;
  }
  return i->region < j->region;
}
int main() {
  int n, m;
  char buffer[40];
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int region, rate;
    cin >> buffer >> region >> rate;
    a[i] = new st(new string(buffer), region, rate);
  }
  sort(a, a + n, cmp);
  a[n] = new st(new string(""), 11000, 11000);
  int i = 0;
  int curIndex = 1;
  while (curIndex <= m) {
    while (a[i]->region == a[i + 1]->region) {
      i++;
    }
    if (i >= 2) {
      if (a[i - 1]->region == a[i - 2]->region &&
          a[i - 1]->rate == a[i - 2]->rate) {
        cout << "?" << endl;
      } else {
        cout << *(a[i - 1]->name) << " " << *(a[i]->name) << endl;
      }
    } else {
      cout << *(a[0]->name) << " " << *(a[1]->name) << endl;
    }
    i++;
    curIndex++;
  }
  return 0;
}
