#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int t, p;
  cin >> t;
  while (t--) {
    cin >> p;
    cout << 2 << " " << p - 1 << endl;
  }
}
