## Grid Sums

View as PDF

Points: 3
Time limit: 1.0s
Memory limit: 16M

Problem type
##### Peg Test - March 9

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

#### Input Specification

, followed by the rows of the grid on separate lines. will be less than or equal to .
, how many different sets of and to input.
and on the same line after the grid.

#### Output Specification

The sum of the numbers in row and column .

#### Sample Input

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

#### Sample Output

24
30