P12024 [AOJ] Tokyo Olympics Center
普及
题目描述

Example

Input

3 3 1
1 1 10 10
AAA
A..
A..

Output

100

输入格式

见题面

输出格式

见题面

样例输入
3 3 1 1 1 10 10 AAA A.. A..
样例输出
100