Թաքցված խնդիր
|Այս խնդիրը թաքցված է խմբագրական խրհրդի անդամի կողմից քանի որ կամ այն ոչ ճիշտ լեզվով է գրված,|կամ թեստային տվյալներն են սխալ, կամ խնդրի ձևակերպումը պարզ չէ։|

ACM_0221 - KAREL THE ROBOT

   This sounds like a nice contest problem, doesn’t it? We want to give you an idea what it is like to organize a programming contest. Therefore, your task is to write a validator for the problem described above. (You may read more about validators in the validate problem.)

Input

   The input contains several test cases. The first line of each input contains two space-separated integers: H and W satisfying 1 H, W 100. Each of the following H lines contains exactly W characters describing the maze. The character “X” means a wall, “.” is free terrain, and “E” is free terrain with the exit.

   The next line contains a single integer L, 1 L 10, the length of the program. The last line of the test case contains L characters describing the commands of the program. The character “S” stands for Step, “L” for Left, and “R” for Right.

Output

   Print a single line for each test case. The line must contain “OK” if the robot escapes for every initial position using the given program. Otherwise, the line contains the number of initial positions (including the exit), from which the robot escapes successfully.

Examples

stdin

stdout

1

3 4
E...
X.X.
....
3
SSL
3 3
E..
...
...
3
RSS

5
OK


Ավելացրեց.Հրանտ Հովհաննիսյան
Ամսաթիվ.2014-10-08
Ժամանակի սահմանափակումը.1s
Ծրագրի տեքստի սահմանափակումը.50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Լեզուներ.Բոլորը բացի ASM32 ASM64 GAWK CLPS CLOJURE D ERL FSHARP FORTRAN GOSU HASK ICON ICK NEM NIM OBJC-CLANG PICO PIKE PYPY PYPY3 PY_NBC RUST SCM guile CHICKEN SED TCL WHITESPACE
Աղբյուրը.CTU Open 2014.F

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.