{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003e\n Kazari has an array $A$ length of $L$, she plans to generate an infinite matrix $M$ using $A$.\u003cbr\u003e\n The procedure is given below in C/C++:\u003cbr\u003e\u003cbr\u003e\n int cursor \u003d 0;\u003cbr\u003e\n \u003cpre\u003efor (int i \u003d 0; ; ++i) {\u003cbr\u003e for (int j \u003d 0; j \u0026lt;\u003d i; ++j) { \u003cbr\u003e M[j][i - j] \u003d A[cursor];\u003cbr\u003e cursor \u003d (cursor + 1) % L;\u003cbr\u003e }\u003cbr\u003e}\u003c/pre\u003e\u003cbr\u003e\u003cbr\u003e\n Her friends don\u0027t believe that she has the ability to generate such a huge matrix, so they come up with a lot of queries about $M$, each of which focus the sum over some sub matrix. Kazari hates to spend time on these boring queries. She asks you, an excellent coder, to help her solve these queries.\n\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line of the input contains an integer $T$ $(1 \\le T \\le 100)$ denoting the number of test cases.\u003cbr\u003e\nEach test case starts with an integer $L$ $(1 \\le L \\le 10)$ denoting the length of $A$.\u003cbr\u003e\nThe second line contains $L$ integers $A_0, A_1, ..., A_{L - 1}$ $(1 \\le A_i \\le 100)$.\u003cbr\u003e\nThe third line contains an integer $Q$ $(1 \\le Q \\le 100)$ denoting the number of queries.\u003cbr\u003e\nEach of next $Q$ lines consists of four integers $x_0, y_0, x_1, y_1$ $(0 \\le x_0 \\le x_1 \\le 10 ^ 8, 0 \\le y_0 \\le y_1 \\le 10 ^ 8)$ querying the sum over the sub matrix whose upper-leftmost cell is $(x_0, y_0)$ and lower-rightest cell is $(x_1, y_1)$."}},{"title":"Output","value":{"format":"HTML","content":"For each test case, print an integer representing the sum over the specific sub matrix for each query."}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e\u003cpre\u003e1\t\t\r\n3\t\t\r\n1 10 100\r\n5\t\t\r\n3 3 3 3\r\n2 3 3 3\r\n2 3 5 8\r\n5 1 10 10\r\n9 99 999 1000\u003c/pre\u003e\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e\u003cpre\u003e1\r\n101\r\n1068\r\n2238\r\n33076541\u003c/pre\u003e\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}