欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1562B.Scenes From a Memory
Scenes From a Memory
During the hypnosis session, Nicholas suddenly remembered a positive integer , 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 it's impossible to delete some of its digits to obtain a not prime integer. However, for all 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. is neither a prime nor a composite number.
Input
Each test contains multiple test cases.
The first line contains one positive integer (), denoting the number of test cases. Description of the test cases follows.
The first line of each test case contains one positive integer () — the number of digits in the number.
The second line of each test case contains a positive integer , which doesn't contain zeros in decimal notation (). It is guaranteed that it is always possible to remove less than digits to make the number not prime.
It is guaranteed that the sum of over all test cases does not exceed .
Output
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.
Note
In the first test case, you can't delete digits from the number , as all the numbers , , and are prime. However, you can delete digit, obtaining a number .
In the second test case, you can delete all digits except one, as is a composite number.
Samples
7
3
237
5
44444
3
221
2
35
3
773
1
4
30
626221626221626221626221626221
2
27
1
4
1
1
2
35
2
77
1
4
1
6
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |