#include <bits/stdc++.h>
//#include <atcoder/all>

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef vector<bool> VB;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) LL((a).size())

#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define ROF(i,a,b) for(LL i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL LARGE_INT = 1e9+100;
const LL INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const LL MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL TIME_LIMIT = 1992;

LL start_time;
string result_string;
LL result_point=0;
LL h=50;
LL w=50;
VVL t;
VVL p;

void check(string result, LL point){
    if(point > result_point){
        result_point = point;
        result_string = result;
    }
}

void dfs(LL x, LL y, VB v, string result, LL point){
    LL time = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
    if(time-start_time > TIME_LIMIT){
        check(result, point);
        return;
    }

    v[t[x][y]]=true;

    VL dx={1,-1,0,0};
    VL dy={0,0,1,-1};

    VVL tp;

    REP(i,4){
        LL nx = x+dx[i];
        LL ny = y+dy[i];
        if(nx >= h || nx < 0 || ny >= w || ny < 0){
            continue;
        }
        if(v[t[nx][ny]]){
            continue;
        }
        LL dist = min(nx,h-nx)*min(nx,h-nx) + min(ny,w-ny)*min(ny,w-ny);

        tp.PB({-dist,p[nx][ny],i,nx,ny});
    }

    if(tp.empty()){
        check(result, point);
        return;
    }

    SORT_DESC(tp);

    for(auto w : tp){
        LL np = w[1];
        LL i = w[2];
        LL nx = w[3];
        LL ny = w[4];
        //cerr<<np<<" "<<i<<" "<<nx<<" "<<ny<<endl;
        string d;
        if(i==0){
            d = "D";
        }
        if(i==1){
            d = "U";
        }
        if(i==2){
            d = "R";
        }
        if(i==3){
            d = "L";
        }
        dfs(nx, ny, v, result+d, point+np);
    }
}

void Main()
{
    start_time = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
    //dump(start_time)
    LL si,sj;cin>>si>>sj;

    t.resize(h);
    REP(i,h){
        t[i].resize(w);
        REP(j,w){
            cin>>t[i][j];
        }
    }
    p.resize(h);
    REP(i,h){
        p[i].resize(w);
        REP(j,w){
            cin>>p[i][j];
        }
    }


    VB v(h*w);
    string result = "";
    LL point = 0;

    dfs(si, sj, v, result, point);

    cout<<result_string<<endl;

    
    
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
#define sz(x) ((int)(x).size()) 
#define all(x) x.begin() , x.end()
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define deb(x) cout<<#x<<"="<<x<<endl
#define debs(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
#define ppc __builtin_popcount
#define ppcll __builtin_popcountll

const int mod = 1000000007;
const int MAX = INT_MAX;
const int MIN = INT_MIN;
const char nl = '\n';
const long long INF = 1e18; 

void build(int64_t  *a, int64_t  *seg,int64_t  s,int64_t  e,int64_t  tind){
    if(s==e){ seg[tind] =a[s-1] ; return ;}
    int64_t  mid = (s+e)/2 ;
    build(a,seg,s,mid,2*tind);
    build(a,seg,mid+1,e,2*tind+1);
    seg[tind] = seg[2*tind]^seg[2*tind+1] ;
}
void update(int64_t  *a,int64_t  *seg,int64_t  s,int64_t  e,int64_t  tind,int64_t  ind ,int64_t  val){
    if(s==e){ a[ind-1]= a[ind-1]^val ; seg[tind] = seg[tind]^val ; return ;}
    int64_t  mid = (s+e)/2 ;
    if(ind>mid)update(a,seg,mid+1,e,2*tind+1,ind,val);
    else update(a,seg,s,mid,2*tind,ind,val) ;
    seg[tind] = seg[2*tind] ^ seg[2*tind+1] ;
}
int64_t  query(int64_t  *seg,int64_t  s,int64_t  e,int64_t  tind,int64_t  l,int64_t  r){
    if(s>r || e<l) return 0 ;
    if(s>=l && e<=r)return seg[tind] ;
    int64_t  mid =(s+e)/2 ;
    return query(seg,s,mid,2*tind,l,r) ^ query(seg,mid+1,e,2*tind+1,l,r);
}

void solve(){
    int64_t  n, k ; cin>>n>>k ;
    int64_t  a[n] ; 
    for(int i=0;i<n;i++){
        cin>>a[i] ;
    }
    int64_t seg[4*n] ;
    mem(seg,0) ;
    build(a,seg,1,n,1);
    while(k--){
        int64_t  c ; cin>>c ;
        if(c==1){
            int64_t  ind , val ; cin>>ind>>val ;
            update(a,seg,1,n,1,ind,val) ;
        }
        else{
            int64_t  l ,r ; cin>>l>>r ;
            cout<<query(seg,1,n,1,l,r)<<endl;
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);cout << fixed;
#ifndef ONLINE_JUDGE
    freopen("F:/input.txt", "r", stdin);
    freopen("F:/output.txt", "w", stdout);
#endif
    int T = 1;
    //cin >> T;
    while (T--) {
        solve();
    } 
}