#include <bits/stdc++.h>

int main(){
    std::string s1, s2, s3;
    std::cin >> s1 >> s2 >> s3;
    
    std::map< int, int > mp;
    
    std::vector< int > s1v(s1.size());
    std::vector< int > s2v(s2.size());
    std::vector< int > s3v(s3.size());
    
    for(int i=0; i<s1.size(); i++){
        auto itr = mp.find(s1[i] - 'a');
        if(itr != mp.end()){
            s1v[i] = mp[s1[i] - 'a'];
        }else{
            if(mp.size() == 10){
                std::cout << "UNSOLVABLE" << std::endl;
                return 0;
            }
            mp[s1[i] - 'a'] = mp.size();
            s1v[i] = mp[s1[i] - 'a'];
        }
    }
    
    for(int i=0; i<s2.size(); i++){
        auto itr = mp.find(s2[i] - 'a');
        if(itr != mp.end()){
            s2v[i] = mp[s2[i] - 'a'];
        }else{
            if(mp.size() == 10){
                std::cout << "UNSOLVABLE" << std::endl;
                return 0;
            }
            mp[s2[i] - 'a'] = mp.size();
            s2v[i] = mp[s2[i] - 'a'];
        }
    }
    
    for(int i=0; i<s3.size(); i++){
        auto itr = mp.find(s3[i] - 'a');
        if(itr != mp.end()){
            s3v[i] = mp[s3[i] - 'a'];
        }else{
            if(mp.size() == 10){
                std::cout << "UNSOLVABLE" << std::endl;
                return 0;
            }
            mp[s3[i] - 'a'] = mp.size();
            s3v[i] = mp[s3[i] - 'a'];
        }
    }
    
    std::deque< std::vector< int > > per_all;
    std::vector< int > per(10);
    for(int i=0; i<10; i++){
        per[i] = i;
    }
    per_all.push_back(per);
    for(int i=0; i<10; i++){
        std::deque< std::vector< int > > tmp;
        while(!per_all.empty()){
            per = per_all.front(); per_all.pop_front();
            tmp.push_back(per);
            for(int j=i+1; j<10; j++){
                std::vector< int > per_tmp = per;
                std::swap(per_tmp[i], per_tmp[j]);
                tmp.push_back(per_tmp);
            }
        }
        per_all = tmp;
    }
    
    while(!per_all.empty()){
        per = per_all.front(); per_all.pop_front();
        if(per[s1v[0]] == 0 || per[s2v[0]] == 0 || per[s3v[0]] == 0){
            continue;
        }
        long long n1 = 0, n2 = 0, n3 = 0;
        for(int i=0; i<s1.size(); i++){
            n1 = n1 * 10 + per[s1v[i]];
        }
        for(int i=0; i<s2.size(); i++){
            n2 = n2 * 10 + per[s2v[i]];
        }
        for(int i=0; i<s3.size(); i++){
            n3 = n3 * 10 + per[s3v[i]];
        }
        if(n1 + n2 == n3){
            std::cout << n1 << std::endl;
            std::cout << n2 << std::endl;
            std::cout << n3 << std::endl;
            return 0;
        }
        
    }
    
    std::cout << "UNSOLVABLE" << std::endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define srep(i, l, r) for (int i = (l); i < (r); ++i)
int main(void) {
    char S[3];
    scanf("%c%c%c", &S[2], &S[0], &S[1]);
    printf("%c%c%c", S[0], S[1], S[2]);
    return 0;
}