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

int main() {
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    set<char> s;
    for(char c : s1) s.insert(c);
    for(char c : s2) s.insert(c);
    for(char c : s3) s.insert(c);
    if(s.size() > 10) {
        cout << "UNSOLVABLE" << endl;
        return 0;
    }
    vector<int> ord(10);
    iota(ord.begin(), ord.end(), 0);
    auto len = [&](ll x) -> int {
        return log10(x) + 1;
    };
    do {
        vector<int> mp(26);
        int it = 0;
        for(char c : s) {
            mp[c - 'a'] = ord[it];
            ++it;
        }
        ll a1 = 0, a2 = 0, a3 = 0;
        for(char c : s1) a1 = a1 * 10 + mp[c - 'a'];
        for(char c : s2) a2 = a2 * 10 + mp[c - 'a'];
        for(char c : s3) a3 = a3 * 10 + mp[c - 'a'];
        if(a1 + a2 == a3 && a1 && a2 && a3 && len(a1) == s1.size() && len(a2) == s2.size() && len(a3) == s3.size()) {
            cout << a1 << endl;
            cout << a2 << endl;
            cout << a3 << endl;
            exit(0);
        }
    }while(next_permutation(ord.begin(), ord.end()));
    cout << "UNSOLVABLE" << endl;
}
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define F first
#define S second 
#define YES(n)cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

int main(){
    vector<string> s(3);
    map<char,ll> mp;
    set<char> heads;
    rep(i,3){
        cin>>s[i];
        heads.insert(s[i][0]);
        reverse(all(s[i]));
        ll co=1;
        if(i==2)co=-1;
        for(char c:s[i]){
            mp[c]+=co;
            co*=10;
        }
        reverse(all(s[i]));
    }
    if(mp.size()>10){
        cout<<"UNSOLVABLE"<<endl;
        return 0;
    }
    vector<int> p(10);
    iota(all(p),0);
    do{
        ll tot=0;
        int i=0;
        for(auto x:mp){
            char c=x.first;
            ll co=x.second;
            if(p[i]==0&&heads.count(c)) tot=1e18;
            tot+=co*p[i];
            i++;
        }
        if(tot==0){
            i = 0;
            vector<string> ans(3);
            for(auto& x : mp){
                x.second=p[i];
                ++i;
            }
            rep(i,3){
                ll x=0;
                for(char c:s[i]){
                    x=x*10+mp[c];
                }
                cout<<x<<endl;
            }
            return 0;
        }
    }while(next_permutation(all(p)));
    cout<<"UNSOLVABLE"<<endl;
    return 0;
}