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

void solve() {
    map<char, int> ch;
    string s, t, w;
    cin >> s >> t >> w;
    for (char c : s) ch.emplace(c, 0);
    for (char c : t) ch.emplace(c, 0);
    for (char c : w) ch.emplace(c, 0);
    if (ch.size() > 10) {
        cout << "UNSOLVABLE";
        return;
    }
    int p[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    do {
        string a, b, c;
        int i = 0;
        for (auto it = ch.begin(); it != ch.end(); ++it, i++)
            it->second = p[i];
        for (char x : s) a.push_back(ch[x] + '0');
        for (char x : t) b.push_back(ch[x] + '0');
        for (char x : w) c.push_back(ch[x] + '0');
        ll A = stoll(a), B = stoll(b), C = stoll(c);
        if (a[0] != '0' && b[0] != '0' && c[0] != '0' && A + B == C) {
            cout << a << "\n"
                 << b << "\n"
                 << c << "\n";
            return;
        }
    } while (next_permutation(p, p + 10));
    cout << "UNSOLVABLE";
}

int main() {
  solve();
  
  return 0;
}
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int h, w, x, y;
    cin >> h >> w >> x >> y;

    bool arr[h][w];
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            arr[i][j] = false;
        }
    }

    for (int i = 0; i < h; i++)
    {
        string s;
        cin >> s;
        for (int j = 0; j < w; j++)
        {
            if (s[j] == '.')
                arr[i][j] = true;
        }
    }

    x--;
    y--;

    int finalCount = 0;
    int count = 0;

    for (int i = 0; i < w; i++)
    {
        if (arr[x][i])
            count++;
        else
        {
            if (i > y)
            {
                finalCount+=count;
                break;
            }
            count = 0;
        }

        if (i == w - 1)
            finalCount+=count;
    }

    count = 0;
    for (int i = 0; i < h; i++)
    {
        if (arr[i][y])
            count++;
        else
        {
            if (i > x)
            {
                finalCount+=count;
                break;
            }
            count = 0;
        }

        if (i == h - 1)
            finalCount+=count;
    }

    cout << finalCount - 1 << endl;
}