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