#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) v.begin(), v.end()
template<class T>bool chmax(T& a, const T& b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T& a, const T& b) { if (b<a) { a=b; return 1;} return 0;}

string S1, S2, S3;
vector<char> chars;
char used[10];

bool check() {
    map<char, char> mapping;
    rep(i, 10) if (used[i] != 0) mapping[used[i]] = char('0' + i);

    string T1, T2, T3;
    for (auto c : S1) T1 += mapping[c];
    for (auto c : S2) T2 += mapping[c];
    for (auto c : S3) T3 += mapping[c];

    if (stoll(T1) + stoll(T2) != stoll(T3)) return false;
    if (T1[0] == '0') return false;
    if (T2[0] == '0') return false;
    if (T3[0] == '0') return false;

    cout << T1 << endl << T2 << endl << T3 << endl;
    return true;
}

bool dfs(int cu) {
    if (cu == chars.size()) return check();

    rep(i, 10) {
        if (used[i] != 0) continue;

        used[i] = chars[cu];
        if (dfs(cu + 1)) return true;
        used[i] = 0;
    }

    return false;
}

int main() {
    cin >> S1 >> S2 >> S3;

    for (auto c : S1) chars.push_back(c);
    for (auto c : S2) chars.push_back(c);
    for (auto c : S3) chars.push_back(c);
    sort(all(chars));
    chars.erase(unique(all(chars)), chars.end());

    if (chars.size() > 10) {
        cout << "UNSOLVABLE" << endl;
        return 0;
    }

    bool res = dfs(0);
    if (res == false) cout << "UNSOLVABLE" << endl;
}
#include<bits/stdc++.h>
using namespace std;

using ll=long long;
ll mod=1000000007;

int main(){
    vector<string> S(3);
    for(int i=0;i<3;i++){
        cin >> S[i];
    }
    map<char,ll> P;
    for(int i=0;i<3;i++){
        ll X=1;
        if(i==2){
            X=-1;
        }
        for(int j=S[i].size()-1;j>-1;j--){
            P[S[i][j]]+=X;
            X*=10;
        }
    }
    if(P.size()>10){
        cout << "UNSOLVABLE" << endl;
        return 0;
    }
    vector<int> Q(10);
    iota(Q.begin(),Q.end(),0);
    do{
        ll sum=0;
        int i=0;
        map<char,int> R;
        for(auto it=P.begin();it!=P.end();it++){
            sum+=Q[i]*(*it).second;
            R[(*it).first]=Q[i];
            i++;
        }
        if(sum==0){
            bool a=false;
            for(int i=0;i<3;i++){
                if(R[S[i][0]]==0){
                    a=true;
                    break;
                }
            }
            if(a){
                continue;
            }
            for(int i=0;i<3;i++){
                ll res=0;
                ll X=1;
                for(int j=S[i].size()-1;j>-1;j--){
                    res+=X*R[S[i][j]];
                    X*=10;
                }
                cout << res << endl;
            }
            return 0;
        }
    }while(next_permutation(Q.begin(),Q.end()));
    cout << "UNSOLVABLE" << endl;
}