There are testcases in this problem.The first line has one integer .Then for each testcase, the first line has two integer . The second line has integers denote
For each testcase, output the answer in one line.
3 3 10 0 1 0 1 1000 0 9 1000000 1 0 1 1 0 1 0 0 1
2 501 41667