#include <bits/stdc++.h>
using namespace std;
int solve(int i, int j, string s, string s1, vector<vector<int> > &cal) {
  if (i >= s.size() || j >= s1.size()) return 0;
  if (cal[i][j] != -1) return cal[i][j];
  cal[i][j] = 0;
  if (s[i] == s1[j]) {
    cal[i][j] = 1 + solve(i + 1, j + 1, s, s1, cal);
  }
  cal[i][j] = max(
      cal[i][j], max(solve(i, j + 1, s, s1, cal), solve(i + 1, j, s, s1, cal)));
  return cal[i][j];
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    if (n % 2 != 0) {
      cout << (n - 1) / 2 << " " << (n - 1) << endl;
    } else
      cout << 2 << " " << n / 2 << endl;
  }
}
