欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1474A.Puzzle From the Future
Puzzle From the Future
In the $2022$ year, Mike found two binary integers and of length (both of them are written only by digits and ) that can have leading zeroes. In order not to forget them, he wanted to construct integer in the following way:
- he creates an integer as a result of bitwise summing of and without transferring carry, so may have one or more -s. For example, the result of bitwise summing of and is or the sum of and is ;
- after that Mike replaces equal consecutive digits in by one digit, thus getting . In the cases above after this operation, becomes and becomes (so, won't have equal consecutive digits).
Unfortunately, Mike lost integer before he could calculate himself. Now, to cheer him up, you want to find any binary integer of length such that will be maximum possible as integer.
Maximum possible as integer means that , , and so on.
Input
The first line contains a single integer () — the number of test cases.
The first line of each test case contains the integer () — the length of and .
The second line of each test case contains binary integer of length . The integer consists only of digits and .
It is guaranteed that the total sum of over all test cases doesn't exceed .
Output
For each test case output one binary integer of length . Note, that or may have leading zeroes but must have the same length .
Note
In the first test case, and choosing gives as a result.
In the second test case, so:
- if you choose , will be equal to , so ;
- if you choose , will be equal to , so ;
- if you choose , you'll get .
- If you select , you'll get .
We can show that answer is optimal and is maximum possible.
In the third test case, . If you choose , you'll get and it's the maximum possible .
In the fourth test case, . If you choose , you'll get and it's maximum possible .
In the fifth test case, . If you choose , you'll get and it's maximum possible .
Samples
5
1
0
3
011
3
110
6
111000
6
001011
1
110
100
101101
101110
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |