#include<bits/stdc++.h>

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define Bs binary_search
#define In insert
#define Mp make_pair
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second

const int mx1 = 55;
const int mx2 = 105;
const int mx3 = 1505;
const int mx4 = 10005;
const int mx5 = 200005;
const int mx6 = 1000005;

typedef vector<int> Vi;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vi> VVi;
typedef pair<int, int> Pii;
typedef pair<DD, DD> Pdd;
typedef vector<Pii> Vpi;
typedef vector<Pdd> Vpd;
typedef queue<int> Qi;
typedef stack<int> Si;
typedef deque<int> Di;

int _toggle(int N, int pos) {return N = N ^ (1 << pos);}
int _set(int N, int pos) {return N = N | (1 << pos);}
int _reset(int N, int pos) {return N = N & ~(1 << pos);}
bool _check(int N, int pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

int dx[] = {1, -1, 0, 0, -1, -1, 1, 1};
int dy[] = {0, 0, 1, -1, -1, 1, -1, 1};

///******************************************************///

string s, a, b, c;
char c1, c2, c3;
int n;
Vi d, ans;
bool vis[15];

int fnd(char c, Vi v)
{
    for(int i = 0; i < s.size(); i++){
        if(c == s[i]){
            return v[i];
        }
    }
}

bool check()
{
    LL A = 0, B = 0, C = 0;
    for(int i = 0; i < a.size(); i++){
        A *= 10;
        A += fnd(a[i], d);
    }
    for(int i = 0; i < b.size(); i++){
        B *= 10;
        B += fnd(b[i], d);
    }
    for(int i = 0; i < c.size(); i++){
        C *= 10;
        C += fnd(c[i], d);
    }
    if(A + B == C){
        return 1;
    }
    return 0;
}

void call(int id)
{
    if(id == n){
        if(check()){
            ans = d;
        }
        return;
    }
    for(int i = 0; i < 10; i++){
        if(!vis[i]){
            if(i == 0 && (s[id] == c1 || s[id] == c2 || s[id] == c3)){
                continue;
            }
            vis[i] = 1;
            d.Pb(i);
            call(id + 1);
            d.Bp();
            vis[i] = 0;
        }
    }
}

void solve()
{
    cin >> a >> b >> c;
    c1 = a[0], c2 = b[0], c3 = c[0];
    set<char> st;
    for(int i = 0; i < a.size(); i++){
        st.In(a[i]);
    }
    for(int i = 0; i < b.size(); i++){
        st.In(b[i]);
    }
    for(int i = 0; i < c.size(); i++){
        st.In(c[i]);
    }
    if(st.size() > 10){
        cout << "UNSOLVABLE" << '\n';
        return;
    }
    while(!st.empty()){
        s.Pb(*st.begin());
        st.erase(st.begin());
    }
    n = s.size();
    call(0);
    if(ans.size() == 0){
        cout << "UNSOLVABLE" << '\n';
        return;
    }
    LL A = 0, B = 0, C = 0;
    for(int i = 0; i < a.size(); i++){
        A *= 10;
        A += fnd(a[i], ans);
    }
    for(int i = 0; i < b.size(); i++){
        B *= 10;
        B += fnd(b[i], ans);
    }
    for(int i = 0; i < c.size(); i++){
        C *= 10;
        C += fnd(c[i], ans);
    }
    cout << A << '\n' << B << '\n' << C << '\n';
}

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    int tc = 1;
    //cin >> tc;
    while(tc--){
        solve();
    }
}

#include <stdio.h>
#include <vector>
#include <string.h>

std::vector<int> V;
int check[11];
int value[30], count[30];
int a,b,c, control = 0;
char x[20],y[20],z[20];

void func(int k)
{
	if(control) return;
	if(k==V.size())
	{
		long long int S1 = 0, S2 = 0, S3 = 0;
		if(value[x[1]-'a']==0) return;
		if(value[y[1]-'a']==0) return;
		if(value[z[1]-'a']==0) return;
		
		for(int i=1;i<=a;i++)
		{
			S1*=10;
			S1 += value[x[i]-'a'];
		}
		for(int i=1;i<=b;i++)
		{
			S2*=10;
			S2 += value[y[i]-'a'];
		}
		for(int i=1;i<=c;i++)
		{
			S3*=10;
			S3 += value[z[i]-'a'];
		}
		
		if(S1+S2==S3)
		{
			printf("%lld\n%lld\n%lld",S1,S2,S3);
			control = 1;
		}
		return;
	}
	
	for(int i=0;i<=9;i++)
	{
		if(check[i]==0)
		{
			check[i] = 1;
			value[V[k]] = i;
			func(k+1);
			value[V[k]] = 0;
			check[i] = 0;
		}
	}
	
}
int main()
{
	scanf("%s%s%s",x+1,y+1,z+1);
	a = strlen(x+1);
	b = strlen(y+1);
	c = strlen(z+1);
	for(int i=1;i<=a;i++) count[x[i]-'a']++;
	for(int i=1;i<=b;i++) count[y[i]-'a']++;
	for(int i=1;i<=c;i++) count[z[i]-'a']++;
	
	for(int i=0;i<26;i++) if(count[i]>0) V.push_back(i);
	if(V.size()>10)
	{
		printf("UNSOLVABLE");
		return 0;
	}
	
	
	func(0);
	if(control==0) printf("UNSOLVABLE");
}