Problem: The maps in the game are divided into square cells called Geo Panels. Some of these panels are painted. We shall assume that the Geo Panels without color are painted the transparent color. 

Besides, the map has so-called Geo Symbols. They look like pyramids of different colors (including Geo Symbols of the transparent color). Each Geo Symbol is located on one Geo Panel, and each Geo Panel may contain no more than one Geo Symbol. 

Geo Symbols can be eliminated. To understand better what happens when a Geo Symbol is eliminated, let us introduce some queue to which we will put the recently eliminated Geo Symbols. 

Let's put at the head of the queue a Geo Symbol that was eliminated just now. Next, we will repeat the following operation: 

Extract the Geo Symbol from the queue. Look at the color of the panel containing the given Geo Symbol. If it differs from transparent and differs from the color of the Geo Symbol, then all Geo Panels of this color are repainted in the color of the given Geo Symbol (transparent Geo Symbols repaint the Geo Panels transparent). Repainting is executed in an infinite spiral strictly in the following order starting from the panel, which contained the Geo Symbol: 

<image>

In other words, we select all the panels that need to be repainted and find their numbers in the infinite spiral whose center is placed in the position of the given Geo Symbol. After that, we repaint them in the order of the number's increasing. 

If a panel contains another Geo Symbol and this panel is being repainted, then the Geo Symbol is removed from the field and placed at the tail of the queue. 

After repainting the Geo Symbol is completely eliminated and the next Geo Symbol is taken from the head of the queue (if there is any) and the process repeats. The process ends if the queue is empty. 

See the sample analysis for better understanding. 

You know the colors of all the Geo Panels and the location of all the Geo Symbols. Determine the number of repaintings, which will occur if you destroy one of the Geo Symbols.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 300) — the height and the width of the map (in cells).

Then follow n line; each of them contains m numbers — the Geo Panels' colors.

Then follow n more lines; each of them contains m numbers — the Geo Symbols' description. -1 means that the given position contains no Geo Symbol. Otherwise, the number represents the color of the Geo Symbol in the given position.

All colors are integers from 0 to 109. 0 represents the transparent color.

The last line contains two integers x and y (1 ≤ x ≤ n, 1 ≤ y ≤ m) — the row and the column where the Geo Symbol is placed that needs to be eliminated. The rows are numbered from top to bottom, the columns are numbered from left to right. Coordinates are 1-based. It is guaranteed that the position with coordinates (x, y) contains a Geo Symbol.

Output

Print the single number — the total number of repaintings after the Geo Symbol is eliminated. 

Please, do not use the %lld specificator to read or write 64-bit integers in C++. It is preferred to use the cout stream (you may also use the %I64d specificator).

Examples

Input

5 5
9 0 1 1 0
0 0 3 2 0
1 1 1 3 0
1 1 1 3 0
0 1 2 0 3
-1 1 -1 3 -1
-1 -1 -1 0 -1
-1 -1 -1 -1 -1
-1 2 3 -1 -1
-1 -1 -1 -1 2
4 2


Output

35

Note

All actions of the sample you can see on the following picture: 

<image> If your browser does not support APNG and you see just static image, you can see GIF version of this image by the following link:

http://assets.codeforces.com/images/geo_slow.gif

Solution (in JAVA):

Solution:
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Random;
import java.io.Writer;
import java.util.Collection;
import java.util.List;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.util.ArrayDeque;
import java.io.Reader;
import java.util.Queue;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Niyaz Nigmatullin
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		FastPrinter out = new FastPrinter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskD {

    static final int SHIFT = 400;
    static final int[][] PRECALC;
    static int[] DX = {-1, 0, 1, 0};
    static int[] DY = {0, 1, 0, -1};
    static {
        int all = SHIFT * 2 + 1;
        PRECALC = new int[all][all];
        int x = SHIFT;
        int y = SHIFT;
        int cur = 0;
        int dir = 0;
        int cur2 = 0;
        while (x >= 0 && y >= 0 && x < all && y < all) {
            int step = (cur >> 1) + 1;
            while (x >= 0 && y >= 0 && x < all && y < all && step > 0) {
                PRECALC[x][y] = cur2++;
                x += DX[dir];
                y += DY[dir];
                --step;
            }
            dir = dir + 1 & 3;
            ++cur;
        }
    }

    public void solve(int testNumber, FastScanner in, FastPrinter out) {
        int n = in.nextInt();
        final int m = in.nextInt();
        int[][] a = in.readInt2DArray(n, m);
        int[][] b = in.readInt2DArray(n, m);
        int[] z = new int[n * m * 2 + 1];
        {
            int cur = 0;
            z[cur++] = 0;
            for (int[][] d : new int[][][]{a, b}) {
                for (int[] e : d) {
                    for (int f : e) {
                        if (f >= 0) {
                            z[cur++] = f;
                        }
                    }
                }
            }
            z = Arrays.copyOf(z, cur);
            z = ArrayUtils.sortAndUnique(z);
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    a[i][j] = Arrays.binarySearch(z, a[i][j]);
                    if (b[i][j] >= 0) {
                        b[i][j] = Arrays.binarySearch(z, b[i][j]);
                    }
                }
            }
        }
        int x0 = in.nextInt() - 1;
        int y0 = in.nextInt() - 1;
        int cntColors = z.length;
        List<Integer>[] cells = new List[cntColors];
        List<Integer>[] elements = new List[cntColors];
        for (int i = 0; i < cntColors; i++) {
            cells[i] = new ArrayList<Integer>();
            elements[i] = new ArrayList<Integer>();
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                cells[a[i][j]].add(i * m + j);
                if (x0 == i && y0 == j) {
                    continue;
                }
                if (b[i][j] >= 0) {
                    elements[a[i][j]].add(i * m + j);
                }
            }
        }
        DSU dsu = new DSU(n * m);
        for (int i = 0; i < cntColors; i++) {
            if (cells[i].isEmpty()) {
                continue;
            }
            int first = cells[i].get(0);
            for (int j : cells[i]) {
                dsu.union(first, j);
            }
            dsu.setColor(first, i);
        }
        Queue<Integer> q = new ArrayDeque<Integer>();
        q.add(x0 * m + y0);
        long answer = 0;
        while (!q.isEmpty()) {
            int v = q.poll();
            final int curX = v / m;
            final int curY = v % m;
//            int curColor = a[curX][curY];
            int curColor = dsu.color[dsu.get(v)];
            int nextColor = b[curX][curY];
            if (curColor == 0 || curColor == nextColor || cells[curColor].isEmpty()) {
                continue;
            }
            answer += cells[curColor].size();
            Collections.sort(elements[curColor], new Comparator<Integer>() {
                public int compare(Integer o1, Integer o2) {
                    return getID(o1) - getID(o2);
                }

                private int getID(int v) {
                    int x = v / m;
                    int y = v - x * m;
                    x -= curX;
                    y -= curY;
                    return PRECALC[x + SHIFT][y + SHIFT];
                }
            });
            for (int e : elements[curColor]) {
                q.add(e);
            }
            elements[curColor].clear();
            if (!cells[nextColor].isEmpty()) {
                dsu.union(v, cells[nextColor].get(0));
            }
            if (cells[nextColor].size() < cells[curColor].size()) {
                List<Integer> t = cells[nextColor];
                cells[nextColor] = cells[curColor];
                cells[curColor] = t;
            }
            while (!cells[curColor].isEmpty()) {
                Integer d = cells[curColor].remove(cells[curColor].size() - 1);
                int x = d / m;
                int y = d - x * m;
                a[x][y] = nextColor;
                cells[nextColor].add(d);
            }
            dsu.setColor(v, nextColor);
        }
        out.println(answer);
    }

    static class DSU {
        int[] p;
        int[] color;

        DSU(int n) {
            p = new int[n];
            for (int i = 0; i < n; i++) {
                p[i] = i;
            }
            color = new int[n];
        }

        void setColor(int v, int c) {
            v = get(v);
            color[v] = c;
        }

        int get(int v) {
            return v == p[v] ? v : (p[v] = get(p[v]));
        }

        void union(int v, int u) {
            v = get(v);
            u = get(u);
            p[v] = u;
        }
    }
}

class FastScanner extends BufferedReader {

    boolean isEOF;

    public FastScanner(InputStream is) {
        super(new InputStreamReader(is));
    }

    public int read() {
        try {
            int ret = super.read();
            if (isEOF && ret < 0) {
                throw new InputMismatchException();
            }
            isEOF = ret == -1;
            return ret;
        } catch (IOException e) {
            throw new InputMismatchException();
        }
    }

    static boolean isWhiteSpace(int c) {
        return c >= -1 && c <= 32;
    }

    public int nextInt() {
        int c = read();
        while (isWhiteSpace(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int ret = 0;
        while (!isWhiteSpace(c)) {
            if (c < '0' || c > '9') {
                throw new NumberFormatException("digit expected " + (char) c
                        + " found");
            }
            ret = ret * 10 + c - '0';
            c = read();
        }
        return ret * sgn;
    }

    public int[][] readInt2DArray(int n, int m) {
        int[][] ret = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                ret[i][j] = nextInt();
            }
        }
        return ret;
    }

    }

class FastPrinter extends PrintWriter {

    public FastPrinter(OutputStream out) {
        super(out);
    }

    public FastPrinter(Writer out) {
        super(out);
    }


}

class ArrayUtils {


    static final long seed = System.nanoTime();

    static final Random rand = new Random(seed);

    static public int[] sortAndUnique(int[] a) {
        int[] ret = a.clone();
        sort(ret);
        if (ret.length == 0) {
            return ret;
        }
        int last = ret[0];
        int j = 1;
        for (int i = 1; i < ret.length; i++) {
            if (last != ret[i]) {
                ret[j++] = ret[i];
            }
            last = ret[i];
        }
        return Arrays.copyOf(ret, j);
    }

    public static void sort(int[] a) {
        shuffle(a);
        Arrays.sort(a);
    }

    public static void shuffle(int[] a) {
        for (int i = 0; i < a.length; i++) {
            int j = rand.nextInt(i + 1);
            int t = a[i];
            a[i] = a[j];
            a[j] = t;
        }
    }


    }