//#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define INF 2e9
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
struct Edge{int to; ll w; Edge (int to, ll w) : to(to), w(w) {} };
typedef vector<vector<int> > Graph;
typedef vector<vector<Edge> > Graphw;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
template<class T> void chmax(T& a, T b){if(a<b)a=b;}
template<class T> void chmin(T& a, T b){if(a>b)a=b;}

string s1,s2,s3,S;
map<char, int> mp;
vector<char> vec;
ll kind;
int P[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

int main(){
    cin >> s1 >> s2 >> s3;
    S = s1+s2+s3;
    REP(i,S.length()){
        vec.pb(S[i]);
    }
    sort(vec.begin(),vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());

    REP(i,vec.size()){
        mp[vec[i]] = 0;
    }
    kind = vec.size();

    if(kind > 10){
        cout << "UNSOLVABLE"<<endl;
        return 0;
    }
    
    do {
        ll n1=0,n2=0,n3=0;
        REP(i,mp.size()){
            mp[vec[i]]=P[i];
        }
        if(mp[s1[0]]==0 || mp[s2[0]]==0 ||mp[s3[0]]==0)continue;
        
        //n1
        REP(i,s1.length()){
            n1 = n1*10 + mp[s1[i]];
        }
        REP(i,s2.length()){
            n2 = n2*10 + mp[s2[i]];
        }
        REP(i,s3.length()){
            n3 = n3*10 + mp[s3[i]];
        }
        if(n1+n2==n3){
            cout<<n1<<endl<<n2<<endl<<n3<<endl;
            return 0;
        }


    } while(next_permutation(P, P + 10));

    
    
    cout << "UNSOLVABLE"<<endl;
    return 0;
}
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<string> s(3);
    REP(i,3) cin >> s[i];
    string nm;
    REP(i,26){
        char c = (char)('a'+i);
        REP(j,3){
            bool f = false;
            for(char ci : s[j]){
                if(ci==c){
                    f= true;
                    break;
                }
            }
            if(f){
                nm += c;
                break;
            }
        }
    }
    int nx = nm.size();
    if(nx>10){
        cout << "UNSOLVABLE" << endl;
        return 0;
    }
    vector<char> v(10);
    REP(i,10) v[i]=(char)('0'+i);
    do {
        vector<char> vc(26);
        REP(i,nx){
            vc[(int)(nm[i]-'a')] = v[i];
        }
        bool f = false;
        REP(i,3){
            if(vc[(int)(s[i][0]-'a')]=='0'){
                f=true;
            }
        }
        if(f) continue;
        vector<string> t(3,"");
        REP(i,3){
            for(char c:s[i]){
                t[i] += vc[(int)(c-'a')];
            }
        }
        ll a,b,c;
        a = stoll(t[0]);
        b = stoll(t[1]);
        c = stoll(t[2]);
        if(a+b==c){
            REP(i,3){
                cout << t[i] << endl;
            }
            return 0;
        }
    } while( next_permutation(v.begin(), v.end()) );
    cout << "UNSOLVABLE" << endl;
    return 0;
}