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

int main ()
{
	
	string s[3];
	int per[10]; 
	
	set<char> sc;
	rep(i,3){
		cin>>s[i];
		rep(j,s[i].length()){
			sc.insert(s[i][j]);
		}
	}
	if (sc.size()>10) {
		cout<< "UNSOLVABLE";
		return 0;
	}
	iota (per,per+10,0);
	map<char,int> ci;
	
	int il =0;
	do{
		long num[3]={0};
		bool check = true;
		int ii =0;
		for ( auto it = sc.begin(); it != sc.end();it++ ){
			ci[*it] = per[ii];
			ii++;
		}
		
		rep(i,3){
			rep(j,s[i].length()) {
				int temp = ci[s[i][j]];
				num[i]*=10; num[i]+=temp;
				if (j==0 && temp ==0) check =false;
			}
		}
		if (check== true){
			if (num[0]+num[1]==num[2]){
				cout<<num[0]<<endl<<num[1]<<endl<<num[2];
				return 0;
			}
		}
		
	}while (next_permutation(per,per+10));
	cout<< "UNSOLVABLE";
	return 0;

}


#pragma GCC optimize("O3")

#include <bits/stdc++.h>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// using cint = cpp_int;

#define fastio \
std::cin.tie(nullptr); \
std::ios::sync_with_stdio(false);

using ll = long long;
using ld = long double;

#define For(i, m, n)    for(int i = (m); (i) < (n); ++(i))
#define Rep(i, n)       For(i, 0, n)
#define Each(e, con)    for(auto e: con)
#define rEach(e, con)   for(auto &e: con)
#define crEach(e, con)  for(const auto &e: con)

#define All(con)        (con).begin(), (con).end()
#define Unique(con)     std::sort(All(con)); (con).erase(std::unique(All(con)), (con).end())
#define Reverse(con)    std::reverse(All(con))
#define Middle(con)     (con).begin() + ((con).end() - (con).begin()) / 2

template <class Ty1, class Ty2>
std::istream &operator>>(std::istream &is, std::pair<Ty1, Ty2> &arg)
{ is >> arg.first >> arg.second; return is; }
template <class Ty>
std::istream &operator>>(std::istream &is, std::vector<Ty> &arg)
{ rEach(e, arg) is >> e; return is; }
template <class Ty>
std::istream &operator>>(std::istream &is, std::vector<std::vector<Ty>> &arg)
{ rEach(sub, arg) { rEach(e, sub) { is >> e; }} return is; }

template <class Ty1, class Ty2>
std::istream &vecinput(std::vector<Ty1> &arg1, std::vector<Ty2> &arg2)
{ assert(arg1.size() == arg2.size());
auto sz = arg1.size(); Rep(i, (int)sz) std::cin >> arg1[i] >> arg2[i]; return std::cin; }
template <class Ty1, class Ty2, class Ty3>
std::istream &vecinput(std::vector<Ty1> &arg1, std::vector<Ty2> &arg2, std::vector<Ty3> &arg3)
{ assert(arg1.size() == arg2.size()); assert(arg2.size() == arg3.size());
auto sz = arg1.size(); Rep(i, (int)sz) std::cin >> arg1[i] >> arg2[i] >> arg3[i]; return std::cin; }
template <class Ty1, class Ty2, class Ty3, class Ty4>
std::istream &vecinput(std::vector<Ty1> &arg1, std::vector<Ty2> &arg2, std::vector<Ty3> &arg3, std::vector<Ty4> &arg4)
{ assert(arg1.size() == arg2.size()); assert(arg2.size() == arg3.size()); assert(arg3.size() == arg4.size());
auto sz = arg1.size(); Rep(i, (int)sz) std::cin >> arg1[i] >> arg2[i] >> arg3[i] >> arg4[i]; return std::cin; }

int main() {
fastio

    string a, b, c;
    cin >> a >> b >> c;

    vector<char> alpha;
    crEach(e, a) alpha.push_back(e);
    crEach(e, b) alpha.push_back(e);
    crEach(e, c) alpha.push_back(e);

    Unique(alpha);
    if(alpha.size() > 10) {
        puts("UNSOLVABLE");
        return 0;
    }

    vector<int> digit{0,1,2,3,4,5,6,7,8,9};
    map<char, int> mp;
    do {
        Rep(i, (int)alpha.size()) {
            mp[alpha[i]] = digit[i];
        }

        ll x = 0, y = 0, z = 0;

        if(mp[a[0]] == 0) continue;
        if(mp[b[0]] == 0) continue;
        if(mp[c[0]] == 0) continue;

        Rep(i, (int)a.size()) x = x * 10 + mp[a[i]];
        Rep(i, (int)b.size()) y = y * 10 + mp[b[i]];
        Rep(i, (int)c.size()) z = z * 10 + mp[c[i]];

        if(x + y == z) {
            cout << x << endl;
            cout << y << endl;
            cout << z << endl;
            return 0;
        }
    } while(next_permutation(All(digit)));

    puts("UNSOLVABLE");

    return 0;
}