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;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define INF INT_MAX/2

typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tuple<int, int, int> tiii; // node, cost, parent
typedef long long ll;

struct Comp
{
	bool operator() (tiii a, tiii b)
	{
		return get<1>(a) > get<1>(b);
	}
};

int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { -1, 0, 1, 0 };

int find_index(vector<int> a, int x)
{
	if (a.size() == 0) return -1;

	int l = 0;
	int r = a.size();
	while (l + 1 != r)
	{
		int mid = (l + r) / 2;
		if (a[mid] <= x)
			l = mid;
		else
			r = mid;
	}
	if (a[l] == x)
		return l;
	else
		return -1;
}

int main()
{
	int R, C, M; cin >> R >> C >> M;

	vs grids(R);
	rep(y, 0, R) cin >> grids[y];

	vvi consume(R, vi(C, 0));
	rep(y, 0, R) rep(x, 0, C) cin >> consume[y][x];

	vvi turnon(R, vi(C, 0));
	rep(y, 0, R) rep(x, 0, C) cin >> turnon[y][x];

	vvi turnoff(R, vi(C, 0));
	rep(y, 0, R) rep(x, 0, C) cin >> turnoff[y][x];



	vi order;
	int _x, _y; cin >> _y >> _x;
	int bak = _y * C + _x;
	order.push_back(bak);
	rep(_m, 1, M)
	{
		int y, x; cin >> y >> x;
		int s = y * C + x;

		vi dist(R*C, INF);
		vi back(R*C, -INF);
		priority_queue<tiii, vector<tiii>, Comp> que;
		que.push(tiii(bak, 0, -1));
		dist[bak] = 0;
		while (!que.empty())
		{
			tiii t = que.top(); que.pop();

			int node = get<0>(t);
			int cost = get<1>(t);

			if (back[node] != -INF) continue;
			back[node] = get<2>(t);

			if (node == s) break;

			rep(i, 0, 4)
			{
				int xx = (node % C) + dx[i];
				int yy = (node / C) + dy[i];

				if (xx < 0 || C <= xx) continue;
				if (yy < 0 || R <= yy) continue;
				if (grids[yy][xx] == '#') continue;

				int ss = yy * C + xx;

				if (cost + 1 < dist[ss])
				{
					dist[ss] = cost + 1;
					que.push(tiii(ss, cost + 1, node));
				}
			}
		}

		vi tmp;
		int to = s;
		while (0 <= to)
		{
			tmp.push_back(to);
			to = back[to];
		}
		rep(i, 1, tmp.size()) order.push_back(tmp[tmp.size() - 1 - i]);

		bak = s;
	}



	vvi list(R*C);
	rep(i, 0, order.size()) list[order[i]].push_back(i);

	ll ans = 0;

	vi onoff(R*C, 0);
	ll pluscost = 0;
	rep(i, 0, order.size())
	{
		if (i != 0) ans += pluscost;

		int node = order[i];
		int y = node / C;
		int x = node % C;

		if (onoff[node] == 0) ans += (ll)turnon[y][x];

		int index = find_index(list[node], i);

		if (list[node].size() - 1 == index)
		{
			// last
			ans += (ll)turnoff[y][x];
			if (onoff[node] == 1) pluscost -= (ll)consume[y][x];
			onoff[node] = 0;
			continue;
		}

		if (consume[y][x] * (list[node][index + 1] - list[node][index]) < turnon[y][x] + turnoff[y][x])
		{
			// tukeppa
			if (onoff[node] == 0) pluscost += (ll)consume[y][x];
			onoff[node] = 1;
		}
		else
		{
			ans += (ll)turnoff[y][x];
			if (onoff[node] == 1) pluscost -= (ll)consume[y][x];
			onoff[node] = 0;
		}
	}
	cout << ans << endl;
}