Universal Cup Judging System

Universal Cup

حد الوقت: 1 s حد الذاكرة: 512 MB مجموع النقاط: 100 الصعوبة: [عرض] قابلة للهجوم ✓
الإحصائيات

A robot is located on a 2D Cartesian coordinate system. Initially, the robot is at $(0, 0)$, and Yuki wants to guide the robot to $(x, y)$ using a sequence of instructions.

Specifically, an instruction string consists only of 0 and 1:

  • 0 represents moving one step to the right, changing the robot's position from $(a, b)$ to $(a + 1, b)$.
  • 1 represents moving one step upward, changing the robot's position from $(a, b)$ to $(a, b + 1)$.

Yuki has an instruction string $s = s_1 \dots s_n$ of length $n$ containing only 0, 1, and 2. Yuki must first replace all 2s in the string with either 0 or 1. Then, the robot operates according to the following rule:

  • For every non-negative integer $i$, if the robot is not at $(x, y)$ at time $i$, the robot executes the $((i \bmod n) + 1)$-th instruction of the string.

Yuki wants to find a replacement such that the robot reaches $(x, y)$ and the resulting instruction string is lexicographically as small as possible. You need to help Yuki find the lexicographically smallest instruction string that satisfies the condition, or report that no such string exists.

Input

This problem contains multiple test cases.

The first line contains a positive integer $t$ ($1 \le t \le 10^5$), representing the number of test cases.

For each test case:

  • The first line contains three integers $n, x, y$ ($1 \le n \le 10^6$, $0 \le x, y \le 10^{18}$).
  • The second line contains a string $s$ of length $n$ ($s_i \in \{0, 1, 2\}$).

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

Output

For each test case, output one line:

  • If no such instruction string exists, output -1.
  • If such an instruction string exists, output a string of length $n$ representing the lexicographically smallest valid instruction string.

Examples

Input 1

6
5 2 4
01111
5 3 3
02221
5 3 3
00022
6 1 0
011201
4 8 7
2020
5 0 0
22102

Output 1

01111
00111
-1
011001
-1
00100

Note

For the first test case:

  • Initially, the robot is at $(0, 0)$, and the instruction string is 01111.
  • Following the rules, the robot moves sequentially to $(1, 0)$, $(1, 1)$, $(1, 2)$, $(1, 3)$, $(1, 4)$, $(2, 4)$.
  • Since the robot reaches $(2, 4)$, 01111 is a valid instruction string. It can be proven that 01111 is the lexicographically smallest valid string, so the answer is 01111.

For the second test case:

  • Initially, the robot is at $(0, 0)$, and we replace the instruction string 02221 with 00111.
  • Following the rules, the robot moves sequentially to $(1, 0)$, $(2, 0)$, $(2, 1)$, $(2, 2)$, $(2, 3)$, $(3, 3)$.
  • Since the robot reaches $(3, 3)$, 00111 is a valid instruction string. It can be proven that 00111 is the lexicographically smallest valid string, so the answer is 00111.

For the third test case:

  • It can be proven that there is no way to replace the 2s in the instruction string such that the robot reaches $(3, 3)$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.