#include <bits/stdc++.h>
using namespace std;
constexpr int MOD = 1e9 + 7;
void solve() {
  int P;
  cin >> P;
  cout << 2 << ' ' << P - 1 << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int T;
  T = 1;
  cin >> T;
  while (T--) {
    solve();
  }
}
