eolymp
bolt
Try our new interface for solving problems

UFO

Earth security agency needs to destroy enemy alien spaceship. They already damaged it and forced it to land in a desert. Spaceship is built of unit cube blocks and the bottom layer has the form of a n × m rectangle. Top view of the n = 4, m = 8 spaceship shown in the figure.

prb7472.gif

Spaceship blocks are built from extra-strong metal, that’s why lasers are used for destroying the ship. Laser guns were established by four sides of the spaceship, and they periodically shot laser rays into some blocks of the ship (rays are always perpendicular to the spaceship sides). Each ray destroys R first blocks on its way. If there is one or more blocks atop the destroyed block, they move down.

After k shots it was decided to make an airstrike. For the airstrike it makes sense to choose such area of the ship of size p × p which contains maximal possible number of whole undestroyed blocks. The airstrike will destroy all blocks in this area. Write a program, which calculates the maximal number of whole undestroyed blocks in the area of size p × p which can be destroyed by airstrike.

Input

The first line contains 5 integers: n, m (1nm1 000 000), r (0 < r10), k (0 < k300 000) and p (0 < p ≤ min(n,m,10)). Each of the next n lines contain m numbers. Number in i-th row and j-th column is the number of blocks in the corresponding part of the ship (see a figure). Each number is in range 1..106.

Next k lines contain description of laser shots. Each of these lines contain one symbol and two integers (all separated by spaces). Symbol defines the side of the shot: “W” - west, “E” - east, “S” - south, “N” - north. First integer is the number of row (in case of west or east), or the number of column (in case of north and south), and second number is the height of the shot. Rows and columns numbers correspond to numeration of input data, layers are numbered from one. Each number is in range 1..106.

Output

Output maximal number of undestroyed blocks after k laser shots in the area of size p × p.

Note

prb7472_1.gif

In the figure 2 it’s shown spaceship from the figure 1 after laser shots from example.

Time limit 2 seconds
Memory limit 64 MiB
Input example #1
4 8 2 6 2
1 1 1 1 1 1 1 1
1 2 3 1 1 1 3 1
1 2 1 1 3 1 1 1
1 1 1 1 1 1 1 2
N 2 2
W 2 2
W 2 3
E 2 1
S 4 1
S 7 1
Output example #1
6
Source 2014 X Zhautykov Olympiad Almaty, Kazakhstan, January 12-18