#P176. [Entry U114/T1] 01-strings and 01-subsequences

[Entry U114/T1] 01-strings and 01-subsequences

Source

The problem is proposed by . All rights reserved.

Problem source: http://8.136.99.126/blog/114/686bb169ab85cef1c18668cc

Problem Description

Construct a binary string SS of length nn containing exactly mm subsequences 01\texttt{01}, or determine that no solution exists.

Input Format

This problem contains multiple test cases.

The first line contains a positive integer TT indicating the number of test cases.

Each of the next TT lines contains two non-negative integers nn and mm.

Output Format

If a solution exists, output the constructed 01 string. Otherwise, output nn exclamation marks (!, ASCII code 3333).

Samples

4
2 4
6 8
10 12
14 16
!!
001111
0101011100
11100001111000

Tips

For 50%50\% of the test cases, n100n \le 100 and m104m \le 10^4.

For 100%100\% of the test cases, 1T1041 \le T \le 10^4, 1n1061 \le n \le 10^6, and 0m10180 \le m \le 10^{18}.

It is guaranteed that the sum of nn across all test cases does not exceed 10610^6.