#include <bits/stdc++.h>
using namespace std;
using int64 = int64_t;
const int64 kInfL = 1e15 + 10;
const int kInf = 1e9 + 10;
const int kMod = 1e9 + 7;
void solve() {
  int p;
  cin >> p;
  cout << 2 << ' ' << p - 1 << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
