#include<bits/stdc++.h>
using namespace std;
typedef long long int into;
int main()
  { int h,w,x,y;
   cin>>h>>w>>x>>y;
   x--;y--;
   string s[h];
   for(int i=0;i<h;i++)
    cin>>s[i];
   int ans=0;
   for(int i=x+1;i<h;i++)
   { if(s[i][y]=='#')
      break;
    else ans++; }
   for(int i=x-1;i>=0;i--)
   { if(s[i][y]=='#')
      break;
    else ans++;
   } for(int i=y+1;i<w;i++)
   { if(s[x][i]=='#')
      break;
    else ans++;
   }
   for(int i=y-1;i>=0;i--)
   {  if(s[x][i]=='#')
     break;
    else
      ans++;}
   ans++;
     cout<<ans<<endl;
    
    
   }
     
#include <bits/stdc++.h>
using namespace std;
#define reps(i, a, n) for (int i = (a); i < (n); ++i)
#define rep(i, n) reps(i, 0, n)
#define deps(i, a, n) for (int i = (a); i >= (n); --i)
#define dep(i, n) deps(i, n, 0)

int si, sj;
int t[52][52];
int p[52][52];
int c[52][52];
int score;
vector<char> ans;
int cnt;

void dfs(int i, int j, int score2, vector<char> ans2)
{
	if (cnt++ > 150000)
	{
		//cout << score << endl;
		for (char x : ans) cout << x; cout << endl;
		exit(EXIT_SUCCESS);
	}
	score2 += p[i][j];
	if (score < score2)
	{
		score = score2;
		ans = ans2;
	}

	c[i][j] = 1;
	if (t[i][j] == t[i+1][j]) c[i+1][j] = 1;
	else if (t[i][j] == t[i-1][j]) c[i-1][j] = 1;
	else if (t[i][j] == t[i][j+1]) c[i][j+1] = 1;
	else if (t[i][j] == t[i][j-1]) c[i][j-1] = 1;

	if (c[i+1][j] == 0) {ans2.push_back('D'); dfs(i+1, j, score2, ans2); ans2.erase(ans2.end()-1);}
	if (c[i-1][j] == 0) {ans2.push_back('U'); dfs(i-1, j, score2, ans2); ans2.erase(ans2.end()-1);}
	if (c[i][j+1] == 0) {ans2.push_back('R'); dfs(i, j+1, score2, ans2); ans2.erase(ans2.end()-1);}
	if (c[i][j-1] == 0) {ans2.push_back('L'); dfs(i, j-1, score2, ans2); ans2.erase(ans2.end()-1);}

	c[i][j] = 0;
	if (t[i][j] == t[i+1][j]) c[i+1][j] = 0;
	else if (t[i][j] == t[i-1][j]) c[i-1][j] = 0;
	else if (t[i][j] == t[i][j+1]) c[i][j+1] = 0;
	else if (t[i][j] == t[i][j-1]) c[i][j-1] = 0;
}

signed main(void)
{
	rep (i, 52) c[0][i] = c[51][i] = c[i][0] = c[i][51] = 1;
	cin >> si >> sj;
	reps (i, 1, 51) reps (j, 1, 51) cin >> t[i][j];
	reps (i, 1, 51) reps (j, 1, 51) cin >> p[i][j];
	c[si][sj] = 1;
	if (t[si][sj] == t[si+1][sj]) c[si+1][sj] = 1;
	else if (t[si][sj] == t[si-1][sj]) c[si-1][sj] = 1;
	else if (t[si][sj] == t[si][sj+1]) c[si][sj+1] = 1;
	else if (t[si][sj] == t[si][sj-1]) c[si][sj-1] = 1;

	vector<char> tmp;
	dfs(si+1, sj+1, 0, tmp);
	for (char x : ans) cout << x; cout << endl;
}
