#include <bits/stdc++.h>
using namespace std;

int main(void){
    string S[3];
    cin >> S[0] >> S[1] >> S[2];

    int frag[3][10]={};

    int count=0;//文字数のカウント
    for(int i=0;i<3;i++){
        for(int k=0;k<S[i].size();k++){
            if(frag[i][k]==0){
                count++;
                frag[i][k]=count;
            }
            for(int j=0;j<3;j++){
                for(int h=0;h<S[j].size();h++){
                    if(S[i][k]==S[j][h]) frag[j][h]=frag[i][k];
                }
            }
        }
    }
    /*for(int i=0;i<3;i++){
        for(int j=0;j<S[i].size();j++){
            cout << frag[i][j] << " ";
        }
        cout << endl;
    }*/

    vector<int> v={0,1,2,3,4,5,6,7,8,9};
    bool ok=false;
    long long int N[3];
    do{
        if(count>10) break;
        bool mozisuu=true;

        for(int i=0;i<3;i++){
            N[i]=0;
            if(v[frag[i][0]-1]==0) mozisuu=false;
            for(int j=0;j<S[i].size();j++){
                N[i]+=pow(10,S[i].size()-1-j)*v[frag[i][j]-1];
            }
        }

        if(N[0]+N[1]==N[2] && mozisuu) ok=true;

    }while(next_permutation(v.begin(),v.end()) && !ok );

    if(ok){
        cout << N[0] << endl;
        cout << N[1] << endl;
        cout << N[2] << endl;
    }
    else cout << "UNSOLVABLE" << endl;
}
#include <bits/stdc++.h>
using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int mod = 1e9+7;
int sum(int a, int b){return (a+b) % mod;}
int sub(int a, int b){return (a + mod - b) % mod;}
int mul(int a, int b){return (1ll * a * b) % mod;}
int power(int a,int b){
	int res = 1;
	while(b){
		if(b&1)res = mul(res,a);
		b >>= 1;
		a = mul(a,a);
	}
	return res;
}

#define no cout << "UNSOLVABLE\n";
vii pos[30];
string str[3],res[3];
vector<char> unicos;

bool can(string tmp){
	if(tmp[0] == '0')return 0;
	for(auto &c : tmp)if(c < '0' || c > '9')return 0;
	return 1;
}
ll conv(string tmp){
	stringstream ss(tmp);
	ll x; ss >> x;
	return x;
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	forn(i,0,3){
		cin >> str[i];
		res[i] = str[i];
		forn(j,0,(int)str[i].size()){
			unicos.pb(str[i][j]);
			pos[str[i][j]-'a'].pb({i,j});
		}
	}
	sort(all(unicos));
	unicos.erase(unique(all(unicos)),unicos.end());
	
	//for(auto &x : unicos)cout << x << ' ';
	//cout << '\n';
	
	if(unicos.size() > 10){
		no;
		return 0;
	}
	vi vals;
	forn(i,0,10)vals.pb(i);
	do{
		
		forn(k,0,(int)unicos.size()){
			for(auto &x : pos[unicos[k]-'a']){
				res[x.fi][x.se] = (char)(vals[k]+'0');
			}
		}
		bool es = true;
		forn(i,0,3)if(!can(res[i]))es = false;
		
		if(!es)continue;
		ll n1 = conv(res[0]);
		ll n2 = conv(res[1]);
		ll n3 = conv(res[2]);
		if(n1+n2 == n3){
			cout << n1 << '\n';
			cout << n2 << '\n';
			cout << n3 << '\n';
			return 0;
		}
		
		
	}while(next_permutation(all(vals)));
	
	no;
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/
