#include <bits/stdc++.h>
using namespace std;
const int N = 10005;
const int inf = 1e9;
const int mod = 1e9;
const int base = 1000 * 1000 * 1000;
struct tp {
  pair<int, string> first, second, th;
};
int n, m, a, b;
string s;
tp p[N];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> s >> a >> b;
    if (p[a].first.first <= b) {
      p[a].th.first = p[a].second.first, p[a].th.second = p[a].second.second;
      p[a].second.first = p[a].first.first,
      p[a].second.second = p[a].first.second;
      p[a].first.first = b, p[a].first.second = s;
    } else if (p[a].second.first <= b) {
      p[a].th.first = p[a].second.first, p[a].th.second = p[a].second.second;
      p[a].second.first = b, p[a].second.second = s;
    } else if (p[a].th.first <= b) {
      p[a].th.first = b, p[a].th.second = s;
    }
  }
  for (int i = 1; i <= m; i++) {
    if (p[i].second.first == p[i].th.first && p[i].th.second.size() > 0)
      cout << "?" << endl;
    else {
      cout << p[i].first.second << " " << p[i].second.second << endl;
    }
  }
  return 0;
}
