#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
//const ll INF = numeric_limits<ll>::max() / 4;
//const int INF = numeric_limits<int>::max() / 4;

map<int,set<pair<int,int> > > M; // (moji, (k,d)) dは、その文字の位
vector<bool> F(10,true);
ll X[3];
ll Z[3]; // 最大digit

bool loop(map<int,set<pair<int,int> > >::iterator it, ll x0, ll x1, ll x2){
	if(it == M.end()){
		if(x0 + x1 == x2){
			X[0] = x0;
			X[1] = x1;
			X[2] = x2;
			return true;
		}
		return false;
	}
	auto nt = it;
	nt++;
	for(ll i = 0; i < 10; i++){
		if(!F[i]) continue;
		F[i] = false;
		ll y[3];
		y[0] = x0, y[1] = x1, y[2] = x2;
		bool f = true;
		for(auto jt = it->second.begin(); jt != it->second.end(); jt++){
			if(i == 0 && jt->second == Z[jt->first]) f = false;
			y[jt->first] += i * jt->second;
		}
		if(f){
			if(loop(nt, y[0], y[1], y[2])) return true;
		}
		F[i] = true;
	}
	return false;
}

int main() {
	// ll N;
	string S0, S1, S2;
	cin >> S0 >> S1 >> S2;
	ll d = 1;
	for(int i = S0.length() - 1; 0 <= i; i--){
		int s = S0[i];
		M[s].insert(make_pair(0,d));
		Z[0] = d;
		d *= 10;
	}
	d = 1;
	for(int i = S1.length() - 1; 0 <= i; i--){
		int s = S1[i];
		M[s].insert(make_pair(1,d));
		Z[1] = d;
		d *= 10;
	}
	d = 1;
	for(int i = S2.length() - 1; 0 <= i; i--){
		int s = S2[i];
		M[s].insert(make_pair(2,d));
		Z[2] = d;
		d *= 10;
	}

	int m = M.size();
	if(m > 10){
		cout << "UNSOLVABLE" << endl;
		return 0;
	}

	if(loop(M.begin(),0,0,0)){
		cout << X[0] << endl;
		cout << X[1] << endl;
		cout << X[2] << endl;
		return 0;
	}
	cout << "UNSOLVABLE" << endl;
	return(0);
}

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

#ifdef LOCAL
#include "/debug.h"
#else
#define db(...)
#endif

#define all(v) v.begin(), v.end()
#define pb push_back
using ll = long long;
const int NAX = 2e5 + 5, MOD = 1000000007;

string solveCase(int n, const vector<string> &a)
{
    // TODO: edit here
    vector<int> exist(26);
    vector<char> ss;
    for (auto &x : a)
        for (auto &y : x)
        {
            exist[y - 'a'] = 1;
            ss.pb(y);
        }
    int cnt = count(all(exist), 1);

    sort(all(ss));
    ss.erase(unique(all(ss)), ss.end());

    vector<char> perms;
    for (size_t i = 0; i < 10; i++)
        perms.pb('0' + i);

    if (cnt > 10 || ss.size() > 10)
        return "UNSOLVABLE";

    cnt = 0;
    do
    {
        map<char, char> mp;
        for (size_t i = 0; i < ss.size(); i++)
            mp[ss[i]] = perms[i];
        auto b = a;
        db(mp);
        auto check = [&]() -> bool {
            for (auto &x : b)
                for (auto &y : x)
                    y = mp[y];
            vector<long long> nums(3);
            for (size_t i = 0; i < b.size(); i++)
            {
                for (auto &x : b[i])
                {
                    if ('0' <= x && x <= '9')
                        nums[i] = nums[i] * 10 + x - '0';
                    else
                        return false;
                }
                if (b[i][0] == '0')
                    return false;
            }
            return nums[0] && nums[1] && nums[2] && nums[0] + nums[1] == nums[2];
        };
        if (check())
        {
            string ret;
            for (auto &x : b)
            {
                for (auto &y : x)
                {
                    ret += y;
                }
                ret += "\n";
            }
            ret.pop_back();
            return ret;
        }
    } while (next_permutation(all(perms)));
    return "UNSOLVABLE";
}

// generated by oj-template v4.7.2 (https://github.com/online-judge-tools/template-generator)
int main()
{
#ifndef LOCAL
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif
    constexpr char endl = '\n';
    // failed to analyze input format
    // TODO: edit here
    int n = 3;
    // cin >> n;
    vector<string> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    auto ans = solveCase(n, a);
    // failed to analyze output format
    // TODO: edit here
    cout << ans << endl;
    return 0;
}