#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  long int p, demo, x, y;
  while (t--) {
    cin >> p;
    cout << (p - 1) / 2 << ' ' << (p - 1) << endl;
  }
  return 0;
}
