
/**
*   author:  akifpathan
*   created: Monday 10.05.2021 06:02:17 PM
**/

#ifdef akifpathan
#include "debug.h"
#else
#include<bits/stdc++.h>
using namespace std;
#define debug(x...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());	

void solve()
{
	string a,b,c;
	cin>>a>>b>>c;
	
	vector<char>vec;
	for(char x: a) vec.push_back(x);
	for(char x: b) vec.push_back(x);
	for(char x: c) vec.push_back(x);
	
	sort(vec.begin(),vec.end());
	vec.erase(unique(vec.begin(),vec.end()),vec.end());
	
	if(vec.size()>10)
	{
		cout<<"UNSOLVABLE";
		return;
	}
	
	while(vec.size()<10) vec.push_back('*');
	sort(vec.begin(),vec.end());
	
	auto convert=[&](const string &x)
	{
		ll num=0;
		if(vec[0]==x[0]) return LLONG_MIN;
		for(auto it: x)
		{
			num*=10;
			for(int i=0;i<10;i++) if(vec[i]==it)
			{
				num+=i;
				break;
			}
		}
		return num;
	};
	
	do
	{
		ll x=convert(a);
		ll y=convert(b);
		ll z=convert(c);
		
		if(x+y==z)
		{
			cout<<x<<"\n"<<y<<"\n"<<z;
			return;
		}
	}
	while(next_permutation(vec.begin(),vec.end()));
	
	cout<<"UNSOLVABLE";
}		

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int testcase=1;
	//cin>>testcase;
	
	for(int i=1;i<=testcase;i++)
	{
		//cout<<"Case "<<i<<": ";
		solve();
	}
	
	#ifdef akifpathan
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	#endif
	
	
	return 0;
}


#include <bits/stdc++.h>

int main(){
    std::string s1, s2, s3;
    std::cin >> s1 >> s2 >> s3;
    
    std::map< int, int > mp;
    
    std::vector< int > s1v(s1.size());
    std::vector< int > s2v(s2.size());
    std::vector< int > s3v(s3.size());
    
    for(int i=0; i<s1.size(); i++){
        auto itr = mp.find(s1[i] - 'a');
        if(itr != mp.end()){
            s1v[i] = mp[s1[i] - 'a'];
        }else{
            if(mp.size() == 10){
                std::cout << "UNSOLVABLE" << std::endl;
                return 0;
            }
            mp[s1[i] - 'a'] = mp.size();
            s1v[i] = mp[s1[i] - 'a'];
        }
    }
    
    for(int i=0; i<s2.size(); i++){
        auto itr = mp.find(s2[i] - 'a');
        if(itr != mp.end()){
            s2v[i] = mp[s2[i] - 'a'];
        }else{
            if(mp.size() == 10){
                std::cout << "UNSOLVABLE" << std::endl;
                return 0;
            }
            mp[s2[i] - 'a'] = mp.size();
            s2v[i] = mp[s2[i] - 'a'];
        }
    }
    
    for(int i=0; i<s3.size(); i++){
        auto itr = mp.find(s3[i] - 'a');
        if(itr != mp.end()){
            s3v[i] = mp[s3[i] - 'a'];
        }else{
            if(mp.size() == 10){
                std::cout << "UNSOLVABLE" << std::endl;
                return 0;
            }
            mp[s3[i] - 'a'] = mp.size();
            s3v[i] = mp[s3[i] - 'a'];
        }
    }
    
    std::deque< std::vector< int > > per_all;
    std::vector< int > per(10);
    for(int i=0; i<10; i++){
        per[i] = i;
    }
    per_all.push_back(per);
    for(int i=0; i<10; i++){
        std::deque< std::vector< int > > tmp;
        while(!per_all.empty()){
            per = per_all.front(); per_all.pop_front();
            tmp.push_back(per);
            for(int j=i+1; j<10; j++){
                std::vector< int > per_tmp = per;
                std::swap(per_tmp[i], per_tmp[j]);
                tmp.push_back(per_tmp);
            }
        }
        per_all = tmp;
    }
    
    while(!per_all.empty()){
        per = per_all.front(); per_all.pop_front();
        if(per[s1v[0]] == 0 || per[s2v[0]] == 0 || per[s3v[0]] == 0){
            continue;
        }
        long long n1 = 0, n2 = 0, n3 = 0;
        for(int i=0; i<s1.size(); i++){
            n1 = n1 * 10 + per[s1v[i]];
        }
        for(int i=0; i<s2.size(); i++){
            n2 = n2 * 10 + per[s2v[i]];
        }
        for(int i=0; i<s3.size(); i++){
            n3 = n3 * 10 + per[s3v[i]];
        }
        if(n1 + n2 == n3){
            std::cout << n1 << std::endl;
            std::cout << n2 << std::endl;
            std::cout << n3 << std::endl;
            return 0;
        }
        
    }
    
    std::cout << "UNSOLVABLE" << std::endl;
    return 0;
}

