Scenes From a Memory
Contest: Codeforces Round 741 (Div. 2)
Difficulty rating: 1000
Tags: brute force, constructive algorithms, implementation, math, number theory

During the hypnosis session, Nicholas suddenly remembered a positive integer $$$n$$$, which doesn't contain zeros in decimal notation.

Soon, when he returned home, he got curious: what is the maximum number of digits that can be removed from the number so that the number becomes not prime, that is, either composite or equal to one?

For some numbers doing so is impossible: for example, for number $$$53$$$ it's impossible to delete some of its digits to obtain a not prime integer. However, for all $$$n$$$ in the test cases of this problem, it's guaranteed that it's possible to delete some of their digits to obtain a not prime number.

Note that you cannot remove all the digits from the number.

A prime number is a number that has no divisors except one and itself. A composite is a number that has more than two divisors. $$$1$$$ is neither a prime nor a composite number.

Input format:
Each test contains multiple test cases.

The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 10^3$$$), denoting the number of test cases. Description of the test cases follows.

The first line of each test case contains one positive integer $$$k$$$ ($$$1 \le k \le 50$$$) — the number of digits in the number.

The second line of each test case contains a positive integer $$$n$$$, which doesn't contain zeros in decimal notation ($$$10^{k-1} \le n < 10^{k}$$$). It is guaranteed that it is always possible to remove less than $$$k$$$ digits to make the number not prime.

It is guaranteed that the sum of $$$k$$$ over all test cases does not exceed $$$10^4$$$.

Output format:
For every test case, print two numbers in two lines. In the first line print the number of digits, that you have left in the number. In the second line print the digits left after all delitions.

If there are multiple solutions, print any.

Constraints:
Time limit: 1.0 s
Memory limit: 256.0 MB

Note:
In the first test case, you can't delete $$$2$$$ digits from the number $$$237$$$, as all the numbers $$$2$$$, $$$3$$$, and $$$7$$$ are prime. However, you can delete $$$1$$$ digit, obtaining a number $$$27 = 3^3$$$.

In the second test case, you can delete all digits except one, as $$$4 = 2^2$$$ is a composite number.

Example input:
7
3
237
5
44444
3
221
2
35
3
773
1
4
30
626221626221626221626221626221

Example output:
2
27
1
4
1
1
2
35
2
77
1
4
1
6

Editorial:
Let's show that if a number has three digits, you can always remove at least one from it to get a number that is not prime. This can be proved by a simple brute-force search of all numbers with three digits, but we'll try to do it without a brute-force search.
In fact, if a number contains the digits '1', '4', '6', '8' or '9', then that one digit is the answer, because $$$1$$$, $$$4$$$, $$$6$$$, $$$8$$$ and $$$9$$$ are not prime numbers.
Now let's see what happens if the number doesn't have those digits. Then, if the number has two identical digits, we have found an answer of size two — the number of two identical digits ($$$22$$$, $$$33$$$, $$$55$$$, or $$$77$$$) is divisible by $$$11$$$. Also, if the digits $$$2$$$ or $$$5$$$ are not at the beginning of the number, we again have found an answer of size two — the number of two digits ending in $$$2$$$ or $$$5$$$ is not prime.
If none of the above cases worked, then we find that a three-digit number has one of the following values: $$$237$$$, $$$273$$$, $$$537$$$, $$$573$$$. It is not difficult to see that these numbers have two digits, which form a number, that is divisible by three.
Thus, the maximum answer is two, that is, you can leave no more than two digits in the number. You can find these digits by considering the above cases, or you can just try.
It can be shown that such a brute-force solution will work for $$$O(k)$$$.
Asymptotics: $$$O(k)$$$ per test case.