#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, init, end) for(ll i = init; i < end; i++)
#define REP(i, init, end) for(ll i = init; i < end + 1; i++)
#define rev(i, end, init) for(ll i = init - 1; i >= end; i--)
#define REV(i, end, init) for(ll i = init; i >= end; i--)
#define PI 3.14159265359
// #define EPS 0.0000000001
// #define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


ll getSize(ll N){
    ll count = 0;
    while(N > 0){
        count++;
        N /= 10;
    }

    return count;
}

int main(){
    string S[3];
    rep(i, 0, 3){
        cin >> S[i];
    }

    ll N[3][26];
    ll x;
    rep(i, 0, 3){
        rep(j, 0, 26){
            x = 0;
            rep(k, 0, S[i].size()){
                x *= 10;
                if(S[i][k] - 'a' == j){
                    x += 1;
                }
            }
            N[i][j] = x;
        }
    }

    vector<ll> v = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    ll p;
    ll Nnum[3];
    ll Nsize[3];
    bool moveP;
    bool found = false;
    do{
        p = 0;
        rep(i, 0, 3){
            Nnum[i] = 0;
        }

        rep(j, 0, 26){
            moveP = false;
            rep(i, 0, 3){
                if(N[i][j] != 0){
                    moveP = true;
                }
                Nnum[i] += N[i][j] * v[p];
            }
            if(moveP){
                p++;
            }
        }

        if(Nnum[0] + Nnum[1] == Nnum[2]){
            found = true;
            rep(i, 0, 3){
                if(S[i].size() != getSize(Nnum[i])){
                    found = false;
                }
            }
            if(found){
                break;
            }
        }
    }while(next_permutation(v.begin(), v.end()));

    if(found){
        rep(i, 0, 3){
            cout << Nnum[i] << endl;
        }
    }else{
        cout << "UNSOLVABLE" << endl;
    }

    return 0;
}

#include <bits/stdc++.h>
#define rep(i, begin, end) for (i=begin;i<end;i++)
#define printint(i0, i1) printf("%d %d\n", i0, i1)
#define MAX_N 1000

using namespace std;
typedef long long int ll;
const int inf = 1000000000;
const int mod = 1000000007;
const int nil = -1;
ll i, j, n, m, k, ans;
ll corr[27], exist[27] = {};
ll a[10], b[10], c[10];
vector<ll> chars;


int main() {
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    rep(i,0,s1.length()){
        a[s1.length() - i - 1] = s1[i] - 'a';
        exist[s1[i] - 'a'] = 1;
    }
    rep(i,0,s2.length()){
        b[s2.length() - i - 1] = s2[i] - 'a';
        exist[s2[i] - 'a'] = 1;
    }
    rep(i,0,s3.length()){
        c[s3.length() - i - 1] = s3[i] - 'a';
        exist[s3[i] - 'a'] = 1;
    }
    rep(i,0,27) if (exist[i] == 1) chars.push_back(i);
    if (chars.size() > 10) {
        printf("UNSOLVABLE\n");
        exit(0);
    }
    vector<ll> nums;
    rep(i,0,10) nums.push_back(i);
    do {
        bool flag = false;
        rep(i,0,chars.size()) corr[chars[i]] = nums[i];
        ll n1 = 0, n2 = 0, n3 = 0;
        rep(i,0,s1.length()) {
            n1 += corr[a[i]] * pow(10,i);
            if (i == s1.length()-1 && corr[a[i]] == 0) flag = true;
        }
        rep(i,0,s2.length()) {
            n2 += corr[b[i]] * pow(10,i);
            if (i == s2.length()-1 && corr[b[i]] == 0) flag = true;
        }
        rep(i,0,s3.length()) {
            n3 += corr[c[i]] * pow(10,i);
            if (i == s3.length()-1 && corr[c[i]] == 0) flag = true;
        }
        if (n1 + n2 == n3 && !flag) {
            printf("%lld\n%lld\n%lld\n", n1, n2, n3);
            exit(0);
        }
    } while (next_permutation(nums.begin(), nums.end()));
    printf("UNSOLVABLE\n");

}