#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<pair<int, string> > ans[11111];
struct str {
  string name;
  int team;
  int point;
} a[111111];
bool cmp(str a, str b) { return a.point > b.point; }
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    string s;
    int p, t;
    cin >> a[i].name >> a[i].team >> a[i].point;
  }
  sort(a + 1, a + 1 + n, cmp);
  for (int i = 1; i <= n; i++)
    ans[a[i].team].push_back(make_pair(a[i].point, a[i].name));
  for (int i = 1; i <= m; i++) {
    if (ans[i].size() > 2 && ans[i][1].first == ans[i][2].first)
      cout << "?\n";
    else
      cout << ans[i][0].second << " " << ans[i][1].second << "\n";
  }
}
