An array of length n we have n Each member of this array is a string long k k is…
- User
An array of length n we have n Each member of this array is a string long k k is composed of 0 and 1 (binary string of length k k).
string A span of array, one string long k k is that bit i Its ith is equal to 1 if at least one of the interval strings is bit i Its value should be equal to 1.
The Boolean number of a string is equal to the number of 1 bits.
to you q q is requested and two numbers in each step l , r l,r is given and you have to find the number of the string of the interval [ l , r ] Print [l,r].
input Due to the large volume of input, input is given in an unusual way:
Three numbers in the first line n n and m m and k k has arrived.
in m m next line, in each line first a string k k bits s i s i came Then a number c n t i cnt i came and c n t i cnt i number i n d e x i J index ij It is stated that the field in the house is i n d e x i J index ij of the array equal to s i s i is Each house of the array is guaranteed exactly once as i n d e x index will appear.
In the next line of the number q q has arrived. Then in q q The next line gives you requests in two numbers l , r l,r are given to answer them. 1 ≤ l ≤ r ≤ n ≤ 100
000 1≤l≤r≤n≤100 000 1 ≤ m ≤ 1
000 1≤m≤1 000 1 ≤ k ≤ 3
000 1≤k≤3 000 1 ≤ q ≤ 1
000
000 1≤q≤1 000 000
output in q q Print the answer line for each prompt.
Example Sample input 8 7 5 10001 1 5 10100 1 1 10001 1 3 00100 1 8 00011 1 7 11000 2 2 4 01110 1 6 8 8 8 1 3 3 5 5 6 8 8 6 8 8 8 3 6 Plain text Sample output 1 4 3 5 1 4 1 5 Plain text The members of the array are as follows: 10100 , 11000 , 10001 , 11000 , 10001 , 01110 , 00011 , 00100 10100,11000,10001,11000,10001,01110,00011,00100 In the first request, only the eighth member of the string is mentioned, whose number of 1 bits is equal to one.
In the second request, members 1 to 3 are in the range. The first, second, third and fifth digits of the string of this interval are equal to 1.
In the third request, members 3 to 5 are within the range. The first, second and fifth digits of the string of this interval are equal to 1. write in c++
- Assistant