#include <bits/stdc++.h>
using namespace std;

static const bool LOCAL_TEST = false;

vector<vector<int>> h(30, vector<int>(30, 5000));
vector<vector<int>> v(30, vector<int>(30, 5000));

int si, sj, ti, tj;
int b, result;
double a, e;

int prev_result;
double score;
string path;

void read_h_v()
{
  for (int i = 0; i < 30; ++i)
    for (int j = 0; j < 29; ++j)
      cin >> h.at(i).at(j);
  for (int i = 0; i < 29; ++i)
    for (int j = 0; j < 30; ++j)
      cin >> v.at(i).at(j);
}

void read_s_t_a_e()
{
  cin >> si >> sj >> ti >> tj;
  cin >> a >> e;
}

void read_s_t()
{
  cin >> si >> sj >> ti >> tj;
}

void read_result()
{
  cin >> result;
}

int compute_path_length(int x, int y, char ch)
{
  if (ch == 'L' || ch == 'R')
    return h.at(y).at(x);
  return v.at(y).at(x);
}

int compute_total_path_length(string path)
{
  int x = sj;
  int y = si;

  int len = 0;
  for (char ch : path)
  {
    if (ch == 'L') --x;
    if (ch == 'R') ++x;
    if (ch == 'D') ++y;
    if (ch == 'U') --y;
    len += compute_path_length(x, y, ch);
  }
  return len;
}

void set_avg_path_length(string path, int result, int k)
{
  size_t len = path.size();
  int average = result + (len - 1) / len;
  int x = sj, y = si;
  for (char ch : path)
  {
    if (ch == 'L') --x;
    if (ch == 'R') ++x;
    if (ch == 'D') ++y;
    if (ch == 'U') --y;
    if (ch == 'L' || ch == 'R')
      if (k < 200)
        h.at(y).at(x) = min(h.at(y).at(x), average);
      else
        h.at(y).at(x) = (h.at(y).at(x) + average) / 2;
    else
      if (k < 200)
        v.at(y).at(x) = min(v.at(y).at(x), average);
      else
        v.at(y).at(x) = (v.at(y).at(x) + average) / 2;
  }
}

string query(int prev_result)
{
  string ver = "", hor = "";
  int x = ti - si;
  for (int i = 0; i < x; ++i) ver += "D";
  for (int i = 0; x < i; --i) ver += "U";
  int y = tj - sj;
  for (int i = 0; i < y; ++i) hor += "R";
  for (int i = 0; y < i; --i) hor += "L";

  x = sj, y = si;
  string answer = "";
  while (ver.size() && hor.size())
  {
    char s1 = ver.back(), s2 = hor.back();
    int x1 = x + (s2 == 'R' ? 1 : -1);
    int y1 = y + (s1 == 'D' ? 1 : -1);
    int b1 = compute_path_length(x, y1, s1);
    int b2 = compute_path_length(x1, y, s2);
    char ch;
    if (b1 < b2)
    {
      ch = s1;
      ver.pop_back();
    }
    else if (b2 < b1)
    {
      ch = s2;
      hor.pop_back();
    }
    else
    {
      if (ver.size() < hor.size())
      {
        ch = s2;
        hor.pop_back();
      }
      else
      {
        ch = s1;
        ver.pop_back();
      }
    }
    answer += ch;
    if (ch == 'L') --x;
    if (ch == 'R') ++x;
    if (ch == 'D') ++y;
    if (ch == 'U') --y;
  }
  answer = answer + ver + hor;
  return answer;
}

int main()
{
  if (LOCAL_TEST)
  {
    read_h_v();
  }

  prev_result = 0;
  score = 0.0;

  for (int k = 0; k < 1000; ++k)
  {
    if (LOCAL_TEST)
      read_s_t_a_e();
    else
      read_s_t();

    path = query(prev_result);
    cout << path << endl;

    if (LOCAL_TEST)
    {
      b = compute_total_path_length(path);
      score = score * 0.998 + a / b;
      prev_result = round(b * e);
    }
    else
    {
      read_result();
      prev_result = result;
      set_avg_path_length(path, prev_result, k);
    }
  }
  if (LOCAL_TEST)
  {
    cout << setprecision(32) << round(2312311 * score) << endl;
  }
  return 0;
}

#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i=a; i >=b; i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(), (x).end()

using namespace std;
void _main(); int main() {cin.tie(0); ios::sync_with_stdio(false); _main();}
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1;} return 0;}
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1;} return 0;}

string S1, S2, S3;
#define NOANS "UNSOLVABLE"
vector<char> chars;
char used[10];

bool check() {
    map<char, char> mapping;
    rep(i, 0, 10) {
        if (used[i] != 0) {
            mapping[used[i]] = char('0' + i);
        }
    }

    string SS1, SS2, SS3;
    fore(c, S1) {
        SS1 += mapping[c];
    }
    fore(c, S2) {
        SS2 += mapping[c];
    }
    fore(c, S3) {
        SS3 += mapping[c];
    }

    if (to_string(stoll(SS1)) != SS1) return false;
    if (to_string(stoll(SS2)) != SS2) return false;
    if (to_string(stoll(SS3)) != SS3) return false;
    if(stoll(SS1) + stoll(SS2) != stoll(SS3)) return false;
    if(stoll(SS1) == 0) return false;
    if(stoll(SS2) == 0) return false;
    if(stoll(SS3) == 0) return false;

    cout << SS1 << endl;
    cout << SS2 << endl;
    cout << SS3 << endl;
    return true;
}

bool dfs(int cu) {
    if (cu == chars.size()) return check();

    rep(i, 0, 10) {
        if(used[i] == 0) {
            used[i] = chars[cu];
            if (dfs(cu+1)) return true;
            used[i] = 0;
        }
    }

    return false;
}

void _main() {
    cin >> S1 >> S2 >> S3;

    fore(c, S1) chars.push_back(c);
    fore(c, S2) chars.push_back(c);
    fore(c, S3) chars.push_back(c);
    sort(all(chars));
    chars.erase(unique(all(chars)), chars.end());

    if (10 < chars.size()) {
        cout << NOANS << endl;
        return;
    }

    bool res = dfs(0);
    if(res == false) {
        cout << NOANS << endl;
    }
}