description: Gregor is learning about RSA cryptography, and although he doesn't understand how RSA works, he is now fascinated with prime numbers and factoring them.
  
  Gregor's favorite prime number is P. Gregor wants to find two bases of P. Formally, Gregor is looking for two integers a and b which satisfy both of the following properties.
  
    * P mod a = P mod b, where x mod y denotes the remainder when x is divided by y, and 
    * 2 ≤ a < b ≤ P. 
  
  
  
  Help Gregor find two bases of his favorite prime number!
  
  Input
  
  Each test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 1000).
  
  Each subsequent line contains the integer P (5 ≤ P ≤ {10}^9), with P guaranteed to be prime.
  
  Output
  
  Your output should consist of t lines. Each line should consist of two integers a and b (2 ≤ a < b ≤ P). If there are multiple possible solutions, print any.
  
  Example
  
  Input
  
  
  2
  17
  5
  
  
  Output
  
  
  3 5
  2 4
  
  Note
  
  The first query is P=17. a=3 and b=5 are valid bases in this case, because 17 mod 3 = 17 mod 5 = 2. There are other pairs which work as well.
  
  In the second query, with P=5, the only solution is a=2 and b=4.
solution: 
  
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.OutputStream;
  import java.io.PrintWriter;
  import java.util.InputMismatchException;
  
  public class TaskA {
  
    static class Solver implements Runnable {
  
      int t, n;
      InputReader in;
      PrintWriter out;
  
      void solve() throws IOException {
        t = in.nextInt();
  
        while (t-- > 0) {
          int p = in.nextInt();
          int sqrt = (int) Math.sqrt(p);
  
          for (int i = 2; i <= sqrt; i++) {
            if (valid(p, i)) {
  //            out.println(i + " " + (i * 2));
  
              int zzz = p / i;
  
  
              if (zzz == i) {
                zzz *= 2;
              }
  
              out.println(i + " " + zzz);
              break;
            }
          }
        }
      }
  
      boolean valid(int p, int x) {
  //      return (p % x) == (p % (2 * x));
  
        int zzz = p / x;
  
        if (zzz == x) {
          zzz *= 2;
        }
  
        return (p % x) == (p % zzz);
      }
  
      public Solver(InputReader in, PrintWriter out) {
        this.in = in;
        this.out = out;
      }
  
      @Override
      public void run() {
        try {
          solve();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
  
    }
  
    static class InputReader {
  
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
  
      public int read() {
          if (numChars == -1) {
              throw new InputMismatchException();
          }
  
        if (curChar >= numChars) {
          curChar = 0;
          try {
            numChars = stream.read(buf);
          } catch (IOException e) {
            throw new InputMismatchException();
          }
            if (numChars <= 0) {
                return -1;
            }
        }
  
        return buf[curChar++];
      }
  
      public int nextInt() {
        int c = read();
  
          while (isSpaceChar(c)) {
              c = read();
          }
  
        int sgn = 1;
  
        if (c == '-') {
          sgn = -1;
          c = read();
        }
  
        int res = 0;
  
        do {
            if (c < '0' || c > '9') {
                throw new InputMismatchException();
            }
  
          res *= 10;
          res += c & 15;
  
          c = read();
        } while (!isSpaceChar(c));
  
        return res * sgn;
      }
  
      public int[] nextIntArray(int arraySize) {
        int array[] = new int[arraySize];
  
          for (int i = 0; i < arraySize; i++) {
              array[i] = nextInt();
          }
  
        return array;
      }
  
      public long nextLong() {
        int c = read();
  
          while (isSpaceChar(c)) {
              c = read();
          }
  
        int sign = 1;
  
        if (c == '-') {
          sign = -1;
  
          c = read();
        }
  
        long result = 0;
  
        do {
            if (c < '0' || c > '9') {
                throw new InputMismatchException();
            }
  
          result *= 10;
          result += c & 15;
  
          c = read();
        } while (!isSpaceChar(c));
  
        return result * sign;
      }
  
      public long[] nextLongArray(int arraySize) {
        long array[] = new long[arraySize];
  
          for (int i = 0; i < arraySize; i++) {
              array[i] = nextLong();
          }
  
        return array;
      }
  
      public float nextFloat() {
        float result, div;
        byte c;
  
        result = 0;
        div = 1;
        c = (byte) read();
  
          while (c <= ' ') {
              c = (byte) read();
          }
  
        boolean isNegative = (c == '-');
  
          if (isNegative) {
              c = (byte) read();
          }
  
        do {
          result = result * 10 + c - '0';
        } while ((c = (byte) read()) >= '0' && c <= '9');
  
          if (c == '.') {
              while ((c = (byte) read()) >= '0' && c <= '9') {
                  result += (c - '0') / (div *= 10);
              }
          }
  
          if (isNegative) {
              return -result;
          }
  
        return result;
      }
  
      public double nextDouble() {
        double ret = 0, div = 1;
        byte c = (byte) read();
  
          while (c <= ' ') {
              c = (byte) read();
          }
  
        boolean neg = (c == '-');
  
          if (neg) {
              c = (byte) read();
          }
  
        do {
          ret = ret * 10 + c - '0';
        } while ((c = (byte) read()) >= '0' && c <= '9');
  
          if (c == '.') {
              while ((c = (byte) read()) >= '0' && c <= '9') {
                  ret += (c - '0') / (div *= 10);
              }
          }
  
          if (neg) {
              return -ret;
          }
  
        return ret;
      }
  
      public String next() {
        int c = read();
  
          while (isSpaceChar(c)) {
              c = read();
          }
  
        StringBuilder res = new StringBuilder();
  
        do {
          res.appendCodePoint(c);
  
          c = read();
        } while (!isSpaceChar(c));
  
        return res.toString();
      }
  
      public boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
  
      public String nextLine() {
        int c = read();
  
        StringBuilder result = new StringBuilder();
  
        do {
          result.appendCodePoint(c);
  
          c = read();
        } while (!isNewLine(c));
  
        return result.toString();
      }
  
      public boolean isNewLine(int c) {
        return c == '\n';
      }
  
      public void close() {
        try {
          stream.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
  
      public InputReader(InputStream stream) {
        this.stream = stream;
      }
  
    }
  
    TaskA(InputStream inputStream, OutputStream outputStream) {
      InputReader in = new InputReader(inputStream);
      PrintWriter out = new PrintWriter(outputStream);
      Thread thread = new Thread(null, new Solver(in, out), "Solver", 1 << 29);
  
      try {
        thread.start();
        thread.join();
      } catch (InterruptedException e) {
        e.printStackTrace();
      } finally {
        in.close();
        out.flush();
        out.close();
      }
    }
  
    public static void main(String[] args) {
      new TaskA(System.in, System.out);
    }
  
  }
  