{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":" \n \u003cp\u003eKyle is a student of Programming Monkey Elementary School. Just as others, he is deeply concerned with his grades.\u003c/p\u003e \n \u003cp\u003eLast month, the school held an examination including five subjects, without any doubt, Kyle got a perfect score in every single subject.\u003c/p\u003e \n \u003cp\u003eThere are n students took part in this examination(not including Kyle), and everyone got an integer between 1 to m as the score of one subject.\u003c/p\u003e \n \u003cp\u003eNow, looking at the grade table of these n students, Kyle wants to know how many students still did no better than him even if his scores are something else – Here, “no better” means there is no subject in which the student got strictly greater score than Kyle.\u003c/p\u003e \n "}},{"title":"Input","value":{"format":"HTML","content":" \n \u003cp\u003eThere are multiple test cases.\u003c/p\u003e \n \u003cp\u003eThe first line of the input contains an integer T (T \u0026lt;\u003d 3) which means the number of test cases.\u003c/p\u003e \n \u003cp\u003eThe first line of each test case contains two integers, n, m(n, m≤ 50,000), which are the number of students and the perfect score of each subject.\u003c/p\u003e \n \u003cp\u003eIn the next n lines, each line consists of five integers, indicating a student’s scores.\u003c/p\u003e \n \u003cp\u003eThen one line follows. This line contains an integer q(q≤ 50,000) indicating the number of queries.\u003c/p\u003e \n \u003cp\u003eIn the next q lines, each line contains five integers as well, representing a query. Each query indicates a set of scores, and for each query, you should figure out that if Kyle\u0027s grade is this set of scores, how many students still did no better than him. But for the sake of security, only the first query is in its original form, and other queries are encrypted. To decrypt a query, you must let each integer in the query do xor operation with the answer of last query. It\u0027s guaranteed that all the decrypted queries contain integers between 1 and 50000.\u003c/p\u003e \n "}},{"title":"Output","value":{"format":"HTML","content":" \n \u003cp\u003eFor each test case, you should output q lines as the answer for all queries.\u003c/p\u003e \n "}},{"title":"Sample Input","value":{"format":"HTML","content":" \n \u003cpre\u003e2\r\n2 3\r\n1 1 1 1 1\r\n2 2 2 2 2 \r\n2\r\n1 1 1 1 1\r\n3 3 3 3 3\r\n3 5\r\n1 1 1 1 1\r\n1 1 1 1 1\r\n1 2 3 4 5\r\n2\r\n1 1 1 1 1\r\n1 1 1 1 1\u003c/pre\u003e \n "}},{"title":"Sample Output","value":{"format":"HTML","content":" \n \u003cpre\u003e1\r\n2\r\n2\r\n2\u003c/pre\u003e \n "}},{"title":"Hint","value":{"format":"HTML","content":" \n \u003cp\u003eIn case 1, there are two students with different scores and the scores of the first student (1, 1, 1, 1, 1) are not larger than the first query (1 1 1 1 1) in every subject, so the answer for this query is 1.\u003c/p\u003e \n \u003cp\u003eAfter having xor operation with the last answer 1, the second query (3,3,3,3,3) will be decrypted into (2, 2, 2, 2, 2). Because both students’ scores are no better than \u0026nbsp;(2, 2, 2, 2, 2), so the answer for query 2 is 2.\u003c/p\u003e \n \u003c/div\u003e \n "}}]}