Algorithm


A. Gregor and Cryptography
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

  • Pmoda=Pmodb�mod�=�mod�, where xmody�mod� denotes the remainder when x is divided by y, and
  • 2a<bP2≤�<�≤�.

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 (1t10001≤�≤1000).

Each subsequent line contains the integer P (5P1095≤�≤109), with P guaranteed to be prime.

Output

Your output should consist of t lines. Each line should consist of two integers a and b (2a<bP2≤�<�≤�). If there are multiple possible solutions, print any.

Example
input
Copy
2
17
5
output
Copy
3 5
2 4
Note

The first query is P=17�=17a=3�=3 and b=5�=5 are valid bases in this case, because 17mod3=17mod5=217mod3=17mod5=2. There are other pairs which work as well.

In the second query, with P=5�=5, the only solution is a=2�=2 and b=4�=4.

 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming

#include<bits/stdc++.h>
using namespace std;


#define ll long long
#define endl '\n'
#define debug(n) cout<<(n)<<endl;
const ll INF = 2e18 + 99;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int t;
  cin>>t;
  int n;
  while(t--){
    cin>>n;
    n--;
    cout<<2<<" "<<n<<endl;
  }

}
Copy The Code & Try With Live Editor

Input

x
+
cmd
2
17
5

Output

x
+
cmd
3 5
> 2 4
Advertisements

Demonstration


Codeforcess Solution 1549-A A. Gregor and Cryptography ,C++, Java, Js and Python,1549-A,Codeforcess Solution

Previous
Codeforces solution 1080-B-B. Margarite and the best present codeforces solution
Next
CodeChef solution DETSCORE - Determine the Score CodeChef solution C,C+