← Home
write a go solution for F1. Xor of Median (Easy Version)time limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output  This is the easy version of the problem. The difference between the versions is that in this version, the constraints on t, k, and m are lower. You can hack only if you solved all versions of this problem. A sequence a of n integers is called good if the following condition holds:  Let cnt_x be the number of occurrences of x in sequence a. For all pairs 0<=i<j<m, at least one of the following has to be true: cnt_i=0, cnt_j=0, or cnt_i<=cnt_j. In other words, if both i and j are present in sequence a, then the number of occurrences of i in a is less than or equal to the number of occurrences of j in a. You are given integers n and m. Calculate the value of the bitwise XOR of the median^∗ of all good sequences a of length n with 0<=a_i<m. Note that the value of n can be very large, so you are given its binary representation instead.^∗The median of a sequence a of length n is defined as the lfloorn+1/2rfloor-th smallest value in the sequence.InputEach test contains multiple test cases. The first line contains the number of test cases t (1<=t<=50). The description of the test cases follows. The first line of each test case contains two integers k and m (1<=k<=200, 1<=m<=500) — the number of bits in n and the upper bound on the elements in sequence a.The second line of each test case contains a binary string of length k — the binary representation of n with no leading zeros.It is guaranteed that the sum of k over all test cases does not exceed 200. OutputFor each test case, output a single integer representing the bitwise XOR of the median of all good sequences a of length n where 0<=a_i<m.ExampleInput62 3102 3115 1111017 9110101117 34110010100010100101 5001Output3
2
0
8
32
0
NoteIn the first example, n=10_2=2 and m=3. All possible sequences with elements less than m are: [0,0], [0,1], [0,2], [1,0], [1,1], [1,2], [2,0], [2,1], [2,2]. All of them are good, so the answer is: 0oplus0oplus0oplus0oplus1oplus1oplus0oplus1oplus2=3.In the second example, n=11_2=3 and m=3. Some good sequences are [2,2,2], [1,0,1], and [2,0,1]. However, a sequence [2,0,0] is not good, because cnt_0=2, cnt_2=1. Therefore, if we set i=0 and j=2, i<j holds, but cnt_i<=cnt_j does not.. Output only the code with no comments, explanation, or additional text.