#include <bits/stdc++.h>
// #include <atcoder/all>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
// using namespace atcoder;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    string s[3];
    int n[3] = {};
    int f[26] = {};
    rep(i,3){
        cin >> s[i];
        n[i] = s[i].size();
        rep(j,n[i]) f[s[i][j]-'a'] = 1;
    } 
    int cnt = 0;
    rep(i,26) cnt += f[i];
    if(cnt > 10){
        cout << "UNSOLVABLE" << endl;
        return 0;
    }

    int g[256] = {};
    int now = 0;
    rep(i,26){
        if(f[i]){
            g[i+'a'] = now;
            now++;
        }
    }


    const int N = 10;
    vector<int> v(N);
    iota(v.begin(), v.end(), 0);       // v に 0, 1, 2, ... N-1 を設定
    do {
        int ng = 0;
        ll x[3] = {};
        rep(i,3){
            rep(j,n[i]){
                if(j == 0 && v[g[s[i][j]]] == 0){
                    ng = 1;
                    break;
                }
                x[i] *= 10;
                x[i] += v[g[s[i][j]]];
            }
            if(ng) break;
        }
        if(ng == 0 && x[0]+x[1]==x[2]){
            rep(i,3){
                rep(j,n[i]) cout << v[g[s[i][j]]];
                cout << endl;
            }
            return 0;
        }
    } while( next_permutation(v.begin(), v.end()) );     // 次の順列を生成
    cout << "UNSOLVABLE" << endl;
    return 0;
}



#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

template<typename T>
bool vector_match(T t, vector<T> vec) {
	for (T v : vec) {
		if (v == t)return true;
	}
	return false;
}

vector<char> getUsedChar(string str) {
	vector<char> used;
	for (char c : str) {
		if (!vector_match(c, used)) used.push_back(c);
	}
	return used;
}

bool isLess10char(vector<char> used) {
	if (used.size() <= 10) return true;
	else return false;
}

string replaceChar(string str, char change, char changed) {
	for (int i = 0; i < str.size(); i++) {
		if (str[i] == change) str[i] = changed;
	}
	return str;
}

vector<int> solve(const int& depth, const vector<char>& usedc, const vector<int>& usedi, string s1, string s2, string s3) {
	if (depth != usedc.size()) {
		for (int i = '0' + 0; i < '0' + 10; i++) {
			if (i == '0' && (s1[0] == usedc[depth] || s2[0] == usedc[depth] || s3[0] == usedc[depth])) continue;
			vector<int> new_usedi = usedi;
			if (!vector_match(i, usedi)) {
				new_usedi.push_back(i);
				vector<int> ans = solve(depth + 1, usedc, new_usedi, replaceChar(s1, usedc[depth], i), replaceChar(s2, usedc[depth], i), replaceChar(s3, usedc[depth], i));
				if (ans.size() != 0) return ans;
			}
		}
	}
	else {
		if (stol(s1) + stol(s2) == stol(s3)) return usedi;
		else return vector<int>();
	}
	return vector<int>();
}

int main() {

	string S[3];

	cin >> S[0] >> S[1] >> S[2];

	vector<char> used = getUsedChar(S[0] + S[1] + S[2]);
	vector<int> ans;
	if (!isLess10char(used)) cout << "UNSOLVABLE" << endl;
	else {
		ans = solve(0, used, vector<int>(), S[0], S[1], S[2]);
		if (ans.size() == 0) cout << "UNSOLVABLE" << endl;
		else {
			for (int i = 0; i < ans.size(); i++) {
				S[0] = replaceChar(S[0], used[i], ans[i]);
				S[1] = replaceChar(S[1], used[i], ans[i]);
				S[2] = replaceChar(S[2], used[i], ans[i]);
			}
			cout << S[0] << endl << S[1] << endl << S[2] << endl;
		}
	}
	return 0;

}