#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

template <typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef unsigned long long ull;
#define pi 3.14159265358979323846264338327950
#define ll long long
#define ld long double
#define boost ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)((x).size())
#define mem1(a) memset(a, -1, sizeof(a))
#define mem0(a) memset(a, 0, sizeof(a))

////debug template-----------------------------
#ifndef ONLINE_JUDGE
#define what(x...)                \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define what(x...)
#endif
//----
void __print(int x) { cerr << x; }
void __print(ll x) { cerr << x; }
void __print(ull x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(ld x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x)
{
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x)
{
    int f = 0;
    cerr << '{';
    for (auto &i : x)
        cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v)
{
    __print(t);
    if (sizeof...(v))
        cerr << ", ";
    _print(v...);
}
/////--------Debug template End----------->
////Deepak Prajapati----------------------------------------------->

const ll mxN = 1e5 + 10;
const ld eps = 1e-6;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

// vector<pair<int, int>> moves = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
// vector<vector<int>> g;
// vector<bool> vis;

void solve(int tc)
{
    vector<int> a(3);
    for (auto &&i : a)
    {
        cin >> i;
    }
    sort(all(a));
    cout << a[1] + a[2] << "\n";
}

int main()
{
    boost;
    cout << setprecision(10) << fixed;
    int tc = 1;
    // cal();
    // sieve();
    // cin >> tc;
    for (int i = 1; i <= tc; i++)
    {
        // cout << "Case #" << i << ": ";
        solve(i);
    }
#ifndef ONLINE_JUDGE
    cerr << "Time: " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << " ms\n";
#endif
    return 0;
}
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <bitset>
#include <string>
#include <cstdio>
#include <cmath>
#include <climits>
#include <fstream>
#include <chrono>
using namespace std;

const long long INF = LLONG_MAX;
const long long MOD = 1000000007;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

// input
int sx, sy;
vector<vector<int>> tile(50, vector<int>(50)), point(50, vector<int>(50));

//     UP,0
//     DOWN,1
//     LEFT,2
//     RIGHT,3
const int dx[] = {0, 0, -1, 1};
const int dy[] = {-1, 1, 0, 0};
char output(int move)
{
    switch (move)
    {
    case 0:
        return 'U';
    case 1:
        return 'D';
    case 2:
        return 'L';
    case 3:
        return 'R';
    default:
        return 'U';
    }
}

void change(int& x, int& y, const int& move)
{
    x += dx[move];
    y += dy[move];
}

int move_point(const int& now_x, const int& now_y, const int& move, const vector<char>& visited)
{
    int next_x = now_x + dx[move];
    int next_y = now_y + dy[move];

    if (next_x < 0 || 50 <= next_x) return 0;
    if (next_y < 0 || 50 <= next_y) return 0;

    if (visited[tile[next_y][next_x]] == 'o') return 0;
    if (tile[next_y][next_x] == tile[now_y][now_x]) return 0;

    return point[next_y][next_x];
}


int main(void)
{
    // input
    cin >> sy >> sx;
    for (int y = 0; y < 50; y++)
    {
        for (int x = 0; x < 50; x++)
        {
            cin >> tile[y][x];
        }
    }
    for (int y = 0; y < 50; y++)
    {
        for (int x = 0; x < 50; x++)
        {
            cin >> point[y][x];
        }
    }

    vector<char> visited(tile[49][49] + 1, 'x');
    string ans;

    auto start = chrono::system_clock::now();
    auto now = chrono::system_clock::now();
    int now_x = sx, now_y = sy;
    do
    {
        visited[tile[now_y][now_x]] = 'o';

        int max_point = 0;
        int move;
        for (int i = 0; i < 4; ++i)
        {
            if (move_point(now_x, now_y, i, visited) > 0)
            {
                int point = 0;
                switch (i)
                {
                case 0: point = now_y - 1; break;
                case 1: point = 50 - now_y; break;
                case 2: point = now_x - 1; break;
                case 3: point = 50 - now_x; break;
                }

                if (max_point < point)
                {
                    max_point = point;
                    move = i;
                }
            }
        }

        // move
        if (max_point == 0)
        {
            break;
        }
        else
        {
            change(now_x, now_y, move);
            ans += output(move);
        }

        now = chrono::system_clock::now();
    }
    while (chrono::duration_cast<chrono::milliseconds>(now - start).count() < 1900);

    cout << ans << endl;
}