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 <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

typedef pair<int, int> pii;

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

template<class T> constexpr bool in_range(T y, T x, T H, T W) { return 0<=y&&y<H&&0<=x&&x<W; }

struct consumption {
  int on, off, stay;
  consumption(){}
  consumption(int on, int off, int stay): on(on), off(off), stay(stay){}
};

/*------------------------------------------*/
int H, W, M;
vector<string> G;
map<pii, consumption> costs;
vector<pii> vs;
map<pii, int> cnt;
/*------------------------------------------*/

int bfs(pii s, pii t) {

  map<pii, int> dist;
  dist[s] = 0;

  queue<pii> q;
  q.push(s);

  while(!q.empty()) {
    int y, x; tie(y, x) = q.front(); q.pop();
    if(y == t.first && x == t.second) return dist[{y, x}];
    rep(k, 4) {
      int ny = y + dy[k], nx = x + dx[k];
      if(!in_range(ny, nx, H, W)) continue;
      if(G[ny][nx] == '#') continue;
      if(dist.find({ny, nx}) == dist.end()) {
        dist[{ny, nx}] = dist[{y, x}] + 1;
        q.push({ny, nx});
      }
    }
  }
  assert(0);
}

vector<pii> make_path() {
  vector<pii> path = {vs[0]};
  queue<pii> q;
  q.push(vs[0]);
  set<pii> vis;
  vis.insert(vs[0]);
  pii prev[55][55];
  int idx = 0;

  while(!q.empty()) {
    int y, x; tie(y, x) = q.front(); q.pop();
    if(idx + 1 >= vs.size()) continue;
    if(y == vs[idx+1].first && x == vs[idx+1].second) {
      vector<pii> pt;
      pii curr = vs[idx+1];
      for(; curr!=vs[idx]; curr=prev[curr.first][curr.second]) pt.push_back(curr);
      reverse(all(pt)); for(auto& e: pt) path.push_back(e);
      idx ++;
      if(idx == vs.size()) break;
      vis.clear(); vis.insert({y, x});
      while(!q.empty()) q.pop();
    }
    rep(k, 4) {
      int ny = y + dy[k], nx = x + dx[k];
      if(!in_range(ny, nx, H, W)) continue;
      if(G[ny][nx] == '#') continue;
      if(vis.count({ny, nx})) continue;
      vis.insert({ny, nx});
      prev[ny][nx] = {y, x};
      q.push({ny, nx});
    }
  }
  return path;
}

void input() {
  cin >> H >> W >> M;
  G.resize(H);
  rep(i, H) cin >> G[i];

  int C[3][H][W];
  rep(k, 3) rep(i, H) rep(j, W)
    cin >> C[k][i][j];
  rep(i, H) rep(j, W)
    costs[{i, j}] = {C[1][i][j], C[2][i][j], C[0][i][j]};
  rep(i, M) {
    int r, c; cin >> r >> c;
    vs.emplace_back(r, c);
  }
}

int main() {

  input();

  auto path = make_path();
  for(auto e: path)
    cnt[e] ++;

  /*
  for(auto e: path) {
    cout << endl;
    rep(i, H) rep(j, W) {
      if(e.first == i && e.second == j) cout << "o";
      else cout << G[i][j];
      if(j == W - 1) cout << endl;
    }
  }
  */

  int ans = 0;
  map<pii, int> dist;
  int currdist = 0;
  pii prev = vs[0];

  for(auto && e: path) {
    currdist += bfs(prev, e);
    if(dist.find(e) == dist.end()) {
      ans += costs[e].on;
    } else {
      ans += min(costs[e].off + costs[e].on, costs[e].stay * (currdist - dist[e]));
    }
    if(cnt[e] == 1) {
      ans += costs[e].off;
    }
    cnt[e] --;
    dist[e] = currdist;
    prev = e;
  }

  cout << ans << endl;
  
  return 0;
}