#P360. 【例62.2】 相邻数之和

【例62.2】 相邻数之和

Description

Please write a program to calculate the sum of adjacent numbers for a given point in a 2D array. Adjacent numbers refer to the 88 elements surrounding the point. If the point is at a corner or edge, the number of adjacent elements will be reduced accordingly.
For example, in the 4×54 \times 5 2D array aa shown below: The value of element a[2][3]a[2][3] is 77, and its adjacent elements are 8,9,10,5,8,6,8,08, 9, 10, 5, 8, 6, 8, 0 with a sum of 5454. Another example: The value of element a[1][0]a[1][0] is 66, and its adjacent elements are 1,2,7,3,41, 2, 7, 3, 4 with a sum of 1717.

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

Input Format

First line contains 44 integers: hh, ll, cc, rr representing the height and width of the 2D array, and the row and column indices of the specified point respectively.
Next hh lines contain the l×hl \times h int type 2D array aa. Where 2h,l102 \le h, l \le 10; and 0c,r90 \le c, r \le 9; note that indices start from 00.

Output Format

The sum of adjacent elements of a[c][r]a[c][r].

Sample

4 5 2 3
1 2 3 4 5
6 7 8 9 10
3 4 5 7 8
2 5 6 8 0
54