Problem: Saving electricity is very important!

You are in the office represented as R \times C grid that consists of walls and rooms. It is guaranteed that, for any pair of rooms in the office, there exists exactly one route between the two rooms. It takes 1 unit of time for you to move to the next room (that is, the grid adjacent to the current room). Rooms are so dark that you need to switch on a light when you enter a room. When you leave the room, you can either leave the light on, or of course you can switch off the light. Each room keeps consuming electric power while the light is on.

Today you have a lot of tasks across the office. Tasks are given as a list of coordinates, and they need to be done in the specified order. To save electricity, you want to finish all the tasks with the minimal amount of electric power.

The problem is not so easy though, because you will consume electricity not only when light is on, but also when you switch on/off the light. Luckily, you know the cost of power consumption per unit time and also the cost to switch on/off the light for all the rooms in the office. Besides, you are so smart that you don't need any time to do the tasks themselves. So please figure out the optimal strategy to minimize the amount of electric power consumed.

After you finished all the tasks, please DO NOT leave the light on at any room. It's obviously wasting!



Input

The first line of the input contains three positive integers R (0 \lt R \leq 50), C (0 \lt C \leq 50) and M (2 \leq M \leq 1000). The following R lines, which contain C characters each, describe the layout of the office. '.' describes a room and '#' describes a wall.

This is followed by three matrices with R rows, C columns each. Every elements of the matrices are positive integers. The (r, c) element in the first matrix describes the power consumption per unit of time for the room at the coordinate (r, c). The (r, c) element in the second matrix and the third matrix describe the cost to turn on the light and the cost to turn off the light, respectively, in the room at the coordinate (r, c).

Each of the last M lines contains two positive integers, which describe the coodinates of the room for you to do the task.

Note that you cannot do the i-th task if any of the j-th task (0 \leq j \leq i) is left undone.

Output

Print one integer that describes the minimal amount of electric power consumed when you finished all the tasks.

Examples

Input

1 3 2
...
1 1 1
1 2 1
1 1 1
0 0
0 2


Output

7


Input

3 3 5
...
.##
..#
1 1 1
1 0 0
1 1 0
3 3 3
3 0 0
3 3 0
5 4 5
4 0 0
5 4 0
1 0
2 1
0 2
2 0
0 0


Output

77


Input

5 5 10
.###
....
.#
..#.#
....
0 12 0 0 0
0 4 3 2 10
0 0 0 99 0
11 13 0 2 0
0 1 1 2 1
0 4 0 0 0
0 13 8 2 4
0 0 0 16 0
1 1 0 2 0
0 2 3 1 99
0 2 0 0 0
0 12 2 12 2
0 0 0 3 0
4 14 0 16 0
0 2 14 2 90
0 1
3 0
4 4
1 4
1 1
4 4
1 1
4 3
3 0
1 4


Output

777

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
using namespace std;

void dfs(bool& end, int a, int b, vector<vector<int> >& adjlist, vector<int>& temp_node, vector<bool>& used){

    //cout << a << " ";
    if(a == b){
        end = true;
        return;
    }

    for(int i = 0; i < adjlist[a].size(); i++){
        
        if(used[adjlist[a][i]] == false){
            used[adjlist[a][i]] = true;
            temp_node.push_back(adjlist[a][i]);
            dfs(end, adjlist[a][i], b, adjlist, temp_node, used);
            if(end) return;
            temp_node.pop_back();
        }
    }
}

int main(){

    int r, c, m; cin >> r >> c >> m;
    vector<vector<bool> > room(r, vector<bool> (c, true));
    vector<vector<int> > on(r, vector<int> (c, 0));
    vector<vector<int> > off(r, vector<int> (c, 0));
    vector<vector<int> > per_time(r, vector<int> (c, 0));
    vector<int> x(m);
    vector<int> y(m);

    //入力
    for(int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            char input; cin >> input;
            if(input == '#') room[i][j] = false;
        }
    }

    for(int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            cin >> per_time[i][j];
        }
    }

    for(int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            cin >> on[i][j];
        }
    }

    for(int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            cin >> off[i][j];
        }
    }
    
    for(int i = 0; i < m; i++){
        cin >> x[i] >> y[i];
    }


    //mapの作成
    map<pair<int, int>, int> M;
    map<int, pair<int, int> > _M;
    int num = 0;
    for(int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            if(room[i][j] == true){
                M[make_pair(i, j)] = num;
                _M[num] = make_pair(i, j);
                num++;
            }
        }
    }

    //隣接リスト
    vector<vector<int> > adjlist(num);

    int di[4] = {0, 1, 0, -1};
    int dj[4] = {1, 0, -1, 0};
    //グラフを作成
    for(int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            if(room[i][j] == true){
                for(int h = 0; h < 4; h++){
                    int ni = i + di[h];
                    int nj = j + dj[h];
                    if(0 <= ni && ni < r && 0 <= nj && nj < c){
                        if(room[ni][nj] == true){
                            int a = M[make_pair(i, j)];
                            int b = M[make_pair(ni, nj)];
                            adjlist[a].push_back(b);
                            //adjlist[b].push_back(a);                            
                        }
                    }
                }
            }
        }
    }
    
    //o

    vector<vector<int> > node(m);         //訪れる頂点の順番の配列
    node[0].push_back(M[make_pair(x[0],y[0])]);
    for(int i = 1; i < m; i++){
        int a = M[make_pair(x[i - 1], y[i - 1])];
        int b = M[make_pair(x[i], y[i])];
        vector<bool> used(num, false);
        bool end = false;
        used[a] = true;
        dfs(end, a, b, adjlist, node[i], used);
    }


    //x


    //訪れる時刻
    int nt = 0;
    vector<vector<int> > t(num, vector<int> (0));
    for(int i = 0; i < node.size(); i++){
        for(int j = 0; j < node[i].size(); j++){
            t[node[i][j]].push_back(nt);
            nt++;
        }
    }

    int ans = 0;
    for(int i = 0; i < num; i++){
        int ni = _M[i].first;
        int nj = _M[i].second;
        
        if(t[i].size() == 0) continue;
        else{
            ans += on[ni][nj] + off[ni][nj];
            for(int j = 1; j < t[i].size(); j++){
                ans += min(on[ni][nj] + off[ni][nj], (t[i][j] - t[i][j - 1])*per_time[ni][nj]);
            }
        }
    }

    cout << ans << endl;

    return 0;    
}