#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <time.h>
using namespace std;

int64_t mod = 998244353 ;

int64_t min(int64_t a,int64_t b) {
    if (a > b)
    {
        return b ;
    }else
    {
        return a ;
    }
}


vector<int> getprime(int n){
    vector<int> p(0) ;
    vector<bool> table(n+1,0) ;
    for (int i = 2; i <= n; i++)
    {
        if (table.at(i) == 0)
        {
            p.push_back(i) ;
            for (size_t j = 2; j < n/i ; j++)
            {
                table.at(i*j) = 1 ;
            }
            
        }
        
    }
    return p ;
}

int getnum(vector<int> &array, vector<char> &c, char a){
    for (int i = 0; i < c.size(); i++)
    {
        if (a == c.at(i))
        {
            return array.at(i) ;
        }
        
    }
    
}



int main(){
    string s1,s2,s3 ;
    cin >> s1 >> s2 >> s3 ;
    vector<int> array(10,0) ;
    for (int i = 0; i < 10; i++)
    {
        array.at(i) = i ;
    }
    vector<char> c(0) ;
    for (int i = 0; i < s1.size(); i++)
    {
        bool ok = 1 ;
        for (int j = 0; j < c.size(); j++)
        {
            if (s1.at(i) == c.at(j))
            {
                ok = 0 ;
                break ;
            }
            
        }
        if (ok)
        {
            c.push_back(s1.at(i)) ;
        }
        
        
    }
    for (int i = 0; i < s2.size(); i++)
    {
        bool ok = 1 ;
        for (int j = 0; j < c.size(); j++)
        {
            if (s2.at(i) == c.at(j))
            {
                ok = 0 ;
                break ;
            }
            
        }
        if (ok)
        {
            c.push_back(s2.at(i)) ;
        }
        
        
    }
    for (int i = 0; i < s3.size(); i++)
    {
        bool ok = 1 ;
        for (int j = 0; j < c.size(); j++)
        {
            if (s3.at(i) == c.at(j))
            {
                ok = 0 ;
                break ;
            }
            
        }
        if (ok)
        {
            c.push_back(s3.at(i)) ;
        }
        
        
    }
    /*
    for (int i = 0; i < c.size(); i++)
    {
        cout << c.at(i) ;
    }
    */
    
    if (c.size() > 10)
    {
        cout << "UNSOLVABLE" << endl ;
        return 0 ;
    }
    
    do 
    {
        bool ng = 0 ;
        int64_t n1 = 0 ;
        int64_t n2 = 0 ;
        int64_t n3 = 0 ;
        for (int i = 0; i < s1.size(); i++)
        {
            int next = getnum(array,c,s1.at(i)) ;
            if (i == 0 && next == 0)
            {
                ng = 1 ;
                break ;
            }else
            {
                n1 = n1*10 + next ;
            }
            
            
        }
        for (int i = 0; i < s2.size(); i++)
        {
            int next = getnum(array,c,s2.at(i)) ;
            if (i == 0 && next == 0)
            {
                ng = 1 ;
                break ;
            }else
            {
                n2 = n2*10 + next ;
            }
            
            
        }
        for (int i = 0; i < s3.size(); i++)
        {
            int next = getnum(array,c,s3.at(i)) ;
            if (i == 0 && next == 0)
            {
                ng = 1 ;
                break ;
            }else
            {
                n3 = n3*10 + next ;
            }
            
            
        }

        if (ng)
        {
            continue ;
        }
        if (n1 + n2 == n3)
        {
            cout << n1 << endl ;
            cout << n2 << endl ;
            cout << n3 << endl ;

            return 0 ;
        }
        
        
        
    }while ( next_permutation( array.begin(), array.end() ) ) ;
    
    
    cout << "UNSOLVABLE" << endl ;
    

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

#define rep(i, a, b) for (int i = (int)(a); (i) < (int)(b); (i)++)
#define rrep(i, a, b) for (int i = (int)(b) - 1; (i) >= (int)(a); (i)--)
#define all(v) v.begin(), v.end()

typedef long long ll;
template <class T> using V = vector<T>;
template <class T> using VV = vector<V<T>>;

/* 提出時これをコメントアウトする */
#define LOCAL true

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define dbg(x) true
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    constexpr char endl = '\n';
    
    string s[3];
    rep(i,0,3) cin >> s[i];
    map<char,int> v;
    rep(i,0,3) {
        rep(j,0,s[i].size()) {
            v[s[i][j]] = 0;
        }
    }
    string ss = "";
    for (auto e: v) {
        ss.push_back(e.first);
    }
    V<bool> used(10);

    auto dfs = [&] (auto self, int k) -> bool {
        if (k == v.size()) {
            ll n[3] = {};
            rep(i,0,3) {
                rep(j,0,s[i].size()) {
                    if (j == 0 && v[s[i][j]] == 0) return false;
                    n[i] *= 10;
                    n[i] += v[s[i][j]]; 
                }
            }
            return n[0] + n[1] == n[2];
        }
        rep(i,0,10) {
            if (used[i]) continue;
            v[ss[k]] = i;
            used[i] = 1;
            if (self(self, k+1)) return true;
            used[i] = 0;
        }
        return false;
    };

    bool result = dfs(dfs, 0);
    if (v.size() > 10) result = 0;

    if (!result) {
        cout << "UNSOLVABLE" << endl;
    } else {
        rep(i,0,3) {
            rep(j,0,s[i].size()) {
                cout << v[s[i][j]];
            }
            cout << endl;
        }
    }
    return 0;
}