Options

Time limit: 0.6s Memory limit: 64MB Input: Output:

Michael spends his summer holiday at his grandparents’ house, in the Danube Delta. On the first day, he goes fishing with his father to the place where he used to go every day during his childhood. Michael realises that the chosen route is not the only option for covering the distance from his grandparents’ house to the fishing place, so, once he has visited the entire region together with his grandfather, he wonders in how many distinct ways he can cover the distance from their home to the fishing place. The region that Michael knows has a rectangular shape, with the rows numbered from 11 to LL and the columns numbered from 11 to CC. The values 11 represent areas of land and the values 00 represent areas covered by water.

Michael can travel only by land and with the following restriction: from the area (i,j)(i, j) he can go only in one of the areas (i1,j+1)(i-1, j+1), (i,j+1)(i, j+1), (i+1,j+1)(i+1, j+1) – obviously, only if there is land and he does not leave the region. Being an intelligent boy, when Michael visits the surroundings with his grandfather, he notices the following thing: the columns of the matrix which codifies the region are identically repeated every KK. Thus, the column 11, the column K+1K+1, the column 2K+12K+1, \dots are identical. The column 22, the column K+2K+2, the column 2K+22K+2, \dots are identical \dots the column K1K-1, the column K+(K1)K+ (K-1), the column 2K+(K1)2K + (K-1), \dots are identical. Two columns c1c_1 and c2c_2 are identical if the element on the position (i,c1)(i, c_1) is equal to the one on the position (i,c2)(i, c_2) for all i from 11 to LL.

Task

Knowing the coordinates of the place where the grandparents’ house lies and the coordinates of the fishing place that Michael’s father showed him, determine the number of options for covering the distance between them. Two routes are considered distinct if, by writing the sequences of the rows which are visited (in the increasing order of the columns) they differ at least in one position.

Input data

The first line will contain the numbers LL and KK (separated by a space), representing the number of rows of the region and the number KK with the signification mentioned above. On each of the following LL lines, there are KK numbers which can be 00 or 11, not separated by spaces. On the line L+2L+2 there are 2 numbers XX and CC (separated by a space) representing the coordinates (X,C)(X, C) of the fishing place. The grandparents’ house is considered (1,1)(1,1).

Output data

The first line contains a single natural number, modulo 666 013666 \ 013.

Constraints and clarifications

  • 2L,K1002 \leq L, K \leq 100
  • 1X1001 \leq X \leq 100
  • 2C10152 \leq C \leq 10^{15}
  • C1 000C \leq 1 \ 000 for 20%20\% of the tests

Example

stdin

4 3
111
011
110
111
1 4

stdout

4

Log in or sign up to be able to send submissions!