There will be multiple data sets, process the program to the end of file. First line are two integers N and K(N <= 10^5,k <= 7), the second line we have k integers a[i] (1 <= a[i] <= 100). Then I will give you an integer M, which denotes there are questions, (M <= 10^5), for each question, I will give you k integers (b[1],b[2] .... b[k],b[i] <= 10^5,denotes the number of coins each.
900 4
1 2 5 10
2
3 2 3 1
1000 2 2 2
0
27