Peg Test - March 9

Question 3

Given a z by z grid of numbers and two numbers x and y. Output the sum of the numbers in row x and the sum of the numbers in column y.

Input

z, followed by the rows of the grid on separate lines. z will be less than or equal to 10.

T, how many different sets of x and y to input

x and y on the same line after the grid

x,y,T≤100

Output

The sum of the numbers in row x and column y

Sample Input

3
1 2 3
4 5 6
7 8 9
2
1 3
2 2

Sample Output

24
30

All Submissions
Best Solutions


Point Value: 3
Time Limit: 2.00s
Memory Limit: 16M
Added: Mar 08, 2011

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

Comments (Search)

It's quiet in here...