#include <bits/stdc++.h>

#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

using namespace std;

using ld = long double;
using ll = long long int;
using pl = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vpl = vector<pl>;

template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
template <class T> using pq = priority_queue<T>;
template <class T> T chmax(T &a, const T &b) { return a = max(a, b); }
template <class T> T chmin(T &a, const T &b) { return a = min(a, b); }

const ll INF = 100000000000000000;
const ll MAX = 500005;
const ll MOD = 1000000007;
// const ll MOD = 998244353;

int main(void) {

  ll n, k, m;
  cin >> n >> k >> m;

  ll sum = 0;
  rep(i, n - 1) {
    ll a;
    cin >> a;

    sum += a;
  }

  ll diff = max(0LL, n * m - sum);
  cout << (diff > k ? -1LL : diff) << endl;

  return (0);
}

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

struct xy {
	int x;
	int y;
};

const int n = 50;
vector<vector<int>> t(n, vector<int>(n));
vector<vector<int>> p(n, vector<int>(n));
xy s;
clock_t start;
string ans = "";
int maxPoint = 0;

void input () {
  cin >> s.x >> s.y;
	rep(i, n) rep(j, n) cin >> t[i][j];
	rep(i, n) rep(j, n) cin >> p[i][j];
}

bool isTimeLimit(clock_t start) {
  clock_t end = clock();
  const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
  if (time >= 1960) return true;
  else return false;
}

int cnt = 0;
void dfs(int mode, xy now, int point, string tmpans, set<int> step) {
  cnt++;
  // タイムリミット
  if (cnt%500 == 0) {
    if (isTimeLimit(start)) {
      cout << ans << endl;
      exit(0);
    }
  }

  switch (mode) {
    case 0: now.x--; break;
    case 1: now.x++; break;
    case 2: now.y--; break;
    case 3: now.y++; break;
  }

  if (!(now.x >= 0 && now.x <= 49 && now.y >= 0 && now.y <= 49)) {
    return ;
  }
  auto it = step.find(t[now.x][now.y]);
  if (it != step.end()) return;
  step.insert(t[now.x][now.y]);
  switch (mode) {
    case 0: tmpans += "U"; break;
    case 1: tmpans += "D"; break;
    case 2: tmpans += "L"; break;
    case 3: tmpans += "R"; break;
  }

  point += p[now.x][now.y];
  
  if (point > maxPoint) {
    maxPoint = point;
    ans = tmpans;
  }
  
  rep(i, 4) dfs(i, now, point, tmpans, step);
  return;
}

int main() {
	// 入力
  input();

  start = clock();
  rep(i, n) {
    // 初期化
    xy now;
    now.x = s.x;
    now.y = s.y;
    set<int> step; // 踏んだタイル番号を保持
    step.insert(t[now.x][now.y]);
    string tmpans = "";
    int point = 0;


    // 進む方向探索
    // 0：上、1：下、2：左、3：右
    dfs(i, now, point, tmpans, step);
  }
	return 0;
}