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

const ll INF = 1e18;
const int MX = 2005;

int main() {
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    int l1 =s1.size();
    int l2 =s2.size();
    int l3 =s3.size();
    ll n1,n2,n3=-1;
    map<char,int>m;
    for(int i = 0; i < s1.size();i++){
        m[s1[i]] += 1;
        m[s1[0]] += 100;
    }
    for(int i = 0; i < s2.size();i++){
        m[s2[i]] += 1;
        m[s2[0]] += 100;
    }
    for(int i = 0; i < s3.size();i++){
        m[s3[i]] += 1;
        m[s3[0]] += 100;
    }
    if(m.size() > 10){
        cout << "UNSOLVABLE" << endl;
        return 0;
    }
    int array[]={0,1,2,3,4,5,6,7,8,9};
    do{
        ll a=0,b=0,c=0;
        map<int,int>ma;
        int cnt = 0;
        bool skip = false;
        for(auto &x:m){
            if(x.second >= 100 && array[cnt]==0){
                skip = true;
                break;
            }else{
                ma[x.first] = array[cnt];
            }
            cnt++;
        }
        if(!skip){
            for(int i = 0;i < l1;i++){
                a += pow(10,i) * ma[s1[l1-i-1]];
            }
            for(int i = 0;i < l2;i++){
                b += pow(10,i) * ma[s2[l2-i-1]];
            }
            for(int i = 0;i < l3;i++){
                c += pow(10,i) * ma[s3[l3-i-1]];
            }
            if(a + b == c){
                n1 = a;
                n2 = b;
                n3 = c;
                break;
            }
        }
    }while(next_permutation(array,array+10));
    if(n3 == -1){
        cout << "UNSOLVABLE" << endl;
    }else{
        cout << n1 << endl;
        cout << n2 << endl;
        cout << n3 << endl;
    }
}
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>

using namespace std;
using ll = long long;
int n;
int st[10], val[256];
string a, b, c;
bool dfs(int i, int car);
bool search(char c, int i, int car) {
	for(int j = 0; j < 10; ++j) if(!st[j]) {
		st[j] = c;
		val[c] = j;
		if(dfs(i, car)) return true;
		st[j] = 0;
		val[c] = -1;
	}
	return false;
}
bool ok(string& x) {
	return val[x.back()];
}
bool dfs(int i, int car) {
	if(i >= c.size()) return !car && ok(a) && ok(b) && ok(c);

	if(i < a.size() && val[a[i]] == -1) return search(a[i], i, car);

	if(i < b.size() && val[b[i]] == -1) return search(b[i], i, car);
	int va = i >= a.size() ? 0 : val[a[i]];
	int vb = i >= b.size() ? 0 : val[b[i]];
	int res = va + vb + car;
//	printf("%d %d %d\n", va, vb, res);
	if(val[c[i]] == -1) {
		if(st[res%10]) return false;
		val[c[i]] = res % 10;
		st[res % 10] = c[i];
		if(dfs(i + 1, res/10)) return true;
		val[c[i]] = -1;
		st[res%10] = 0;
	}
	else {
		if(val[c[i]] != res % 10) return false;
		if(dfs(i + 1, res / 10)) return true;
	}
	return false;
}

void print(string& x){
	for(auto& c: x) printf("%d", val[c]);
	puts("");
}

int main(){
	cin >> a >> b >> c;
	memset(val, -1, sizeof val);
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());
	reverse(c.begin(), c.end());
	if(dfs(0, 0)) {
		reverse(a.begin(), a.end());
		reverse(b.begin(), b.end());
		reverse(c.begin(), c.end());
		print(a);
		print(b);
		print(c);
	}
	else puts("UNSOLVABLE");
}
