#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long p;
  cin >> p;
  cout << 2 << " " << p - 1 << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long tc;
  cin >> tc;
  while (tc--) solve();
}
