#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;i++)
#define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;i--)
inline int read() {
	int x=0,f=1;char c=getchar();
	while(c<48||c>57){if(c=='-')f=-1;c=getchar();}
	while(c>=48&&c<=57)x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
using namespace std;
char s[105][105];
int main() {
	int n=read(),m=read(),x=read(),y=read();
	rep(i,1,n)scanf("%s",s[i]+1);
	int ly=y;while(ly>=1&&s[x][ly]!='#')ly--;
	int ry=y;while(ry<=m&&s[x][ry]!='#')ry++;
	int lx=x;while(lx>=1&&s[lx][y]!='#')lx--;
	int rx=x;while(rx<=n&&s[rx][y]!='#')rx++;
	printf("%d\n",rx-lx+ry-ly-3);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define pqueue priority_queue
#define umap unordered_map
#define uset unordered_set
#define bits(x) __builtin_popcount((x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x) / gcd(x, y) * (y))
#define inf 4557430888798830399LL
#define mst(dp, val) memset(dp, val, sizeof(dp))
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repd(i, a, b, d) for (int i = a; i <= b; i += d)
#define rep_(i, a, b) for (int i = a; i >= b; --i)
#define repd_(i, a, b) for (int i = a; i >= b; i -= d)
#define mxm(a, b) a = max(a, b) 
#define mnm(a, b) a = min(a, b)
#define L size()
#define pb push_back
#define X first
#define Y second
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << "=" << x << endl
#define readArr(a, n) for (int i = 1; i <= n; i++) cin >> a[i];
#define printArr(a, n) for (int i = 1; i <= n; i++) cout << a[i] << " "; cout << endl;
#define mod 1000000007
#define Add(x, d) x = (x + (d)) % mod
#define print(e) cout << (e) << endl
// #define MULTI_CASES
// #define PRE
const int N = 2e5 + 5;
// int a[N];

void solve() {
    int A, B, C;
    cin >> A >> B >> C;
    C = C % 2 ? 1 : 2;
    int a = pow(A, C), b = pow(B, C);
    if (A == B || a == b) print("=");
    if (a > b) print(">");
    if (a < b) print("<");
}


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    #ifdef MULTI_CASES
        #ifdef PRE
            pre();
        #endif
        int t; cin >> t;
        while (t--) solve();
    #else
        solve();
    #endif
    return 0;
}


