#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef pair<ii, ii> iii;
ll MOD = 1e9 + 7;
const ld E = 1e-9;
#define null NULL
#define ms(x) memset(x, 0, sizeof(x))
#ifndef LOCAL
#define endl "\n"
#endif
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define _read(x) freopen(x, "r", stdin)
#define _write(x) freopen(x, "w", stdout)
#define files(x) _read(x ".in"); _write(x ".out")
#define filesdatsol(x) _read(x ".DAT"); _write(x ".SOL")
#define output _write("output.txt")
#define input _read("input.txt")
#define mod % MOD
#define prev __prev
#define y1 hello_world
unsigned char ccc;
bool _minus = false;
template<typename T>
inline T sqr(T t) {
	return (t * t);
}
inline void read(ll &n) {
	n = 0;
	_minus = false;
	while (true) {
		ccc = getchar();
		if (ccc == ' ' || ccc == '\n')
			break;
		if (ccc == '-') {
			_minus = true;
			continue;
		}
		n = n * 10 + ccc - '0';
	}
	if (_minus)
		n *= -1;
}
inline void read(int &n) {
	n = 0;
	_minus = false;
	while (true) {
		ccc = getchar();
		if (ccc == ' ' || ccc == '\n')
			break;
		if (ccc == '-') {
			_minus = true;
			continue;
		}
		n = n * 10 + ccc - '0';
	}
	if (_minus)
		n *= -1;
}
char wwww[19];
int kkkk;
inline void write(ll y) {
	long long x = y;
	kkkk = 0;
	if (!x)
		++kkkk, wwww[kkkk] = '0';
	else
		while (x) {
			++kkkk;
			wwww[kkkk] = char(x % 10 + '0');
			x /= 10;
		}
	for (int i = kkkk; i >= 1; --i)
		putchar(wwww[i]);
	putchar(' ');
}

#ifdef LOCAL
#define DEBUG
#endif

#ifdef DEBUG
#define dbg if(1)
#else
#define dbg if(0)
#endif

int n, m;

const int MAX = 20;

char ar[MAX][MAX];

ld dp[2][MAX][MAX];

int k;

ii to[MAX][MAX];

vector<ii> go[MAX][MAX];

int X[4] = { 0, 1, 0, -1 };
int Y[4] = { 1, 0, -1, 0 };

int main() {
	sync;
	srand(time(NULL));
	cout.precision(10);
	cout << fixed;
#ifdef LOCAL
	input;
#else

#endif

	cin >> n >> m >> k;

	ii pos;

	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			cin >> ar[i][j];
			to[i][j] = make_pair(-1, -1);
			if(ar[i][j] == 'A') {
				ar[i][j] = 'O';
				pos = make_pair(i, j);
			}
		}
	}

	while(k--) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		a--, b--, c--, d--;
		to[a][b] = make_pair(c, d);
		to[c][d] = make_pair(a, b);
	}

	dp[0][pos.first][pos.second] = 1;
	ld ans = 0;

	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			if(ar[i][j] == '#' || ar[i][j] == '*')
			continue;
			for(int q = 0; q < 4; q++) {
				int x = i + X[q];
				int y = j + Y[q];
				if(0 <= min(x, y) && x < n && y < m && (ar[x][y] == 'O' || ar[x][y] == '%' || ar[x][y] == '*')) {
					go[i][j].push_back(make_pair(x, y));
				}
			}
		}
	}

	ld start = (ld) clock();

	while(true) {
		ld res = 0;
		for(int q = 0; q < 100; q++) {
			ms(dp[1]);
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < m; j++) {
					if(dp[0][i][j] > 0) {
						if(ar[i][j] == '%') {
							res += dp[0][i][j];
						} else {
							if(to[i][j].first != -1) {
								for(ii a : go[to[i][j].first][to[i][j].second]) {
									dp[1][a.first][a.second] += dp[0][i][j] / (ld) go[to[i][j].first][to[i][j].second].size();
								}
							} else
							for(ii a : go[i][j]) {
								dp[1][a.first][a.second] += dp[0][i][j] / (ld) go[i][j].size();
							}
						}
					}
				}
			}
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < m; j++) {
					dp[0][i][j] = dp[1][i][j];
				}
			}
		}
		ans += res;
		if(res < 1e-9)
			break;
	}

	cout << ans << endl;

}