A non-empty string s is called a binary string if it consists only of characters '0' and '1'. A substring s\[l…r] (1≤l≤r≤∣s∣) of string s=s_1s_2…s_∣s∣ (where ∣s∣ is the length of string s) is the string s_ls_l+1…s_r.
Professor Zhang has got a long binary string s starting with '0', and he wants to know whether there is a substring of s such that the number of occurrences of '0' and '1' in this substring are exactly a and b, respectively, where a and b are two given integers.
Since the binary string is very long, we will compress it. The compression method is as follows:
For example, the runs of the binary string "00101100011110111101001111111" are 00,1,0,11,000,1111,0,1111,0,1,00,1111111, so it will be compressed into 2,1,1,2,3,4,1,4,1,1,2,7.
There are multiple test cases. The first line of input contains an integer T, indicating the number of test cases. For each test case:
The first line contains two integers n and m (1≤n≤1000, 1≤m≤5⋅105): the number of runs and the number of queries. The next line contains n integers: x_1,x_2,…,x_n (1≤x_i≤106) indicating the length of each run.
Each of the following m lines contains two integers a_i and b_i (0≤a_i,b_i≤∣s∣, 1≤a_i+b_i≤∣s∣) which means that Professor Zhang wants to know whether there is a substring of s such that the number of occurrences of '0' and '1' in this substring are exactly a_i and b_i, respectively.
There are no more than 200 test cases, and the total size of the input is at most 20 mebibytes. Additionally, the sum of m in all test cases is at most 2⋅106.
For each test case, print a binary string of length m. The i-th digit must be '1' if the answer for the i-th query is "yes", or '0' otherwise.