CF BUDDY
← Problems·

1352F · Binary String Reconstruction

1500 · constructive algorithms, dfs and similar, math

Problem: For some binary string ss (i.e. each character sis_i is either '0' or '1'), all pairs of consecutive (adjacent) characters were written. In other words, all substrings of length 22 were written. For each pair (substring of length 22), the number of '1' (ones) in it was calculated.

You are given three numbers:

  • n0n_0 — the number of such pairs of consecutive characters (substrings) where the number of ones equals 00;
  • n1n_1 — the number of such pairs of consecutive characters (substrings) where the number of ones equals 11;
  • n2n_2 — the number of such pairs of consecutive characters (substrings) where the number of ones equals 22.

For example, for the string s=s="1110011110", the following substrings would be written: "11", "11", "10", "00", "01", "11", "11", "11", "10". Thus, n0=1n_0=1, n1=3n_1=3, n2=5n_2=5.

Your task is to restore any suitable binary string ss from the given values n0,n1,n2n_0, n_1, n_2. It is guaranteed that at least one of the numbers n0,n1,n2n_0, n_1, n_2 is greater than 00. Also, it is guaranteed that a solution exists.

Input Format: The first line contains an integer tt (1t10001 \le t \le 1000) — the number of test cases in the input. Then test cases follow.

Each test case consists of one line which contains three integers n0,n1,n2n_0, n_1, n_2 (0n0,n1,n21000 \le n_0, n_1, n_2 \le 100; n0+n1+n2>0n_0 + n_1 + n_2 > 0). It is guaranteed that the answer for given n0,n1,n2n_0, n_1, n_2 exists.

Output Format: Print tt lines. Each of the lines should contain a binary string corresponding to a test case. If there are several possible solutions, print any of them.

Sample Cases

Case 1

Input

7
1 3 5
1 1 1
3 9 3
0 1 0
3 1 2
0 0 3
2 0 0

Output

1110011110
0011
0110001100101011
10
0000111
1111
000

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback