#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-6;
const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
struct node {
  string name;
  int score;
  node(string _name, int _score) {
    name = _name;
    score = _score;
  }
};
vector<node> no[100010];
bool cmp(node a, node b) { return a.score > b.score; }
int main() {
  int n, m;
  while (~scanf("%d%d", &n, &m)) {
    for (int i = 1; i <= m; i++) no[i].clear();
    int num, score;
    string name;
    for (int i = 0; i < n; i++) {
      cin >> name >> num >> score;
      no[num].push_back(node(name, score));
    }
    for (int i = 1; i <= m; i++) {
      sort(no[i].begin(), no[i].end(), cmp);
      int len = no[i].size();
      if (len > 2 && no[i][1].score == no[i][2].score)
        puts("?");
      else
        cout << no[i][0].name << " " << no[i][1].name << endl;
    }
  }
  return 0;
}
