Description
This problem is a programming version of Problem 41 from projecteuler.net
We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example, 2143 is a 4digit pandigital and is also prime.
What is the largest n-digit pandigital prime ≤N? If there is none, print -1
Input Format
First line contains T that denotes the number of test cases. This is followed by T lines, each containing an integer, N.
Output Format
Print the required answer for each test case.
Constraints
1≤T≤105
10
10≤N≤10 −1
Sample Input
Sample Output




Reviews
There are no reviews yet.