#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
//#define mod 998244353
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using P=pair<int,int>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline void out(T a){ cout << a << '\n'; }
void YN(bool ok){if(ok) cout << "Yes" << endl; else cout << "No" << endl;}
//void YN(bool ok){if(ok) cout << "YES" << endl; else cout << "NO" << endl;}


const ll INF=1e18;
const int mx=200005;

ll t[55][55];
ll p[55][55];

bool check(int i,int j){
    return 0<=i&&i<50&&0<=j&&j<50;
}

int main(){
    //オーバーフローは大丈夫ですか？？
    cin.tie(0);ios::sync_with_stdio(false);
    int si,sj;
    cin>>si>>sj;
    rep(i,50)rep(j,50)cin>>t[i][j];
    rep(i,50)rep(j,50)cin>>p[i][j];
    queue<P> que;
    V<int> seen(3000,0);
    int f=1;
    que.push({si,sj});
    seen[t[si][sj]]=1;
    V<int> dx={-1,0,1,0};
    V<int> dy={0,1,0,-1};
    V<int> C={'U','R','D','L'};
    string ans="";
    int num=0;
    rep(qq,500000){
        int cur=0;
        string S="";
        while(que.size()){
            
            P q=que.front();
            que.pop();
            V<pair<P,pair<char,int>>> v;
            int i=q.ft,j=q.sc;
            rep(k,4){
                if(check(i+dx[k],j+dy[k])&&!seen[t[i+dx[k]][j+dy[k]]]){
                    v.pb({{i+dx[k],j+dy[k]},{C[k],k}});
                }
            }
            if(v.empty()) break;
            if(f==30){
                sort(all(v),[&](auto a,auto b){
                    return p[a.ft.ft][a.ft.sc]>p[b.ft.ft][b.ft.sc];
                });
                S+=v[0].sc.ft;
                que.push(v[0].ft);
                seen[t[v[0].ft.ft][v[0].ft.sc]]=1;
                cur+=p[v[0].ft.ft][v[0].ft.sc];
            }else if(f!=0){
                V<int> cnt(4,0);
                rep(x,50){
                    rep(y,50){
                        if(!seen[t[x][y]]){
                            if(y>=-x+i+j&&y>x-i+j) cnt[0]++;
                            else if(y>-x+i+j) cnt[1]++;
                            else if(y<x-i+j) cnt[2]++;
                            else cnt[3]++;
                        }
                    }
                }
                V<P> Z(4);
                rep(k,4){
                    Z[k]={cnt[k],k};
                }
                sort(all(Z));
                reverse(all(Z));
                rep(k,4){
                    int dir=Z[k].sc;
                    for(auto pp:v){
                        if(pp.sc.sc==dir){
                            que.push(pp.ft);
                            S+=pp.sc.ft;
                            seen[t[pp.ft.ft][pp.ft.sc]]=1;
                            cur+=p[v[0].ft.ft][v[0].ft.sc];
                            goto L;
                        }
                    }
                }
                L:;
                
            }else{
                srand(time(NULL));
                int sz=v.size();
                int k=rand()%sz;
                S+=v[k].sc.ft;
                que.push(v[k].ft);
                seen[t[v[k].ft.ft][v[k].ft.sc]]=1;
                cur+=p[v[0].ft.ft][v[0].ft.sc];
            }
            //f=(f+1)%5;
        }
        if(cur>num){
            num=cur;
            ans=S;
        }
    }
    out(ans);
}
//#include <atcoder/all>
#include <bits/stdc++.h>

using namespace std;

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9+7; //998244353;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}
//using mint = atcoder::modint1000000007;

int main(){
	cin.tie(0); ios_base::sync_with_stdio(false);
	typedef long double DBL;
	int n, m, k;
	cin >>n >>m >>k;
	VI a(n+1);
	rep(i, k){ int q; cin >>q; a[q] =1;}
	vector<DBL> dp(n+4), sm(n+4);
	DBL l=0, r=4e12;
	rep(ii, 200){
		DBL md = (l+r) /2;
		int ck = k;
		dp[n] = sm[n] =0;
		repr(i, n, 0){
			if(a[i]==1) dp[i] = md; 
			else dp[i] = (sm[i+1] - sm[min(n, i+m+1)]) /m +1;
			sm[i] = sm[i+1] + dp[i];
		}
		(dp[0] < md? r: l) = md;
	}
	if(l>=1e12) cout <<"-1\n";
	else cout << fixed << setprecision(10) <<(l+r)/2 <<"\n";

	return 0;
}