#include <bits/stdc++.h>
using namespace std;
char str[4][30],q[20];
int cnt;
int mymap[30];
bool st[30];
bool jdg[20];
long long temp[10];
bool dfs(int s){
    if(s>cnt){
        for(int i=1;i<=3;i++){
            if(mymap[str[i][1]-'a']==0) return false;
        }
        temp[1]=temp[2]=temp[3]=0;
        for(int i=1;i<=3;i++){
            for(int j=1;str[i][j];j++){
                temp[i]=temp[i]*10+mymap[str[i][j]-'a'];
            }
        }
        return temp[1]+temp[2]==temp[3];
    }
    for(int i=0;i<=9;i++){
        if(!jdg[i]){
            mymap[q[s]-'a']=i;
            jdg[i]=true;
            if(dfs(s+1)) return true;
            jdg[i]=false;
        }
    }
    return false;
}
int main(){
    for(int i=1;i<=3;i++) scanf("%s",str[i]+1);
    for(int i=1;i<=3;i++){
        for(int j=1;str[i][j];j++){
            if(!st[str[i][j]-'a']){
                st[str[i][j]-'a']=true;
                q[++cnt]=str[i][j];
            }
        }
    }
    if(cnt>10) puts("UNSOLVABLE");
    else{
        if(dfs(1)){
            for(int i=1;i<=3;i++) cout<<temp[i]<<endl;
        }
        else puts("UNSOLVABLE");
    }
    return 0;
}
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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; }

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};

int arr[] = {0,1,2,3,4,5,6,7,8,9};
map<char,int> mp;
LL getInt(string s){
    reverse(s.begin(), s.end());
    LL res = 0;
    LL base = 1;
    for(char c : s){
        res += base * arr[mp[c]];
        base *= 10;
    }

    return res;

}

bool check(string s){
    int idx = mp[s[0]];
    int x = arr[idx];
    if(x == 0) return false;
    else return true;
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    string A,B,C; cin >> A >> B >> C;
    set<char> se;
    for(char c : A) se.insert(c);
    for(char c : B) se.insert(c);
    for(char c : C) se.insert(c);
    int len = 0;
    for(char c : se) len++;
    if(len > 10){
        cout << "UNSOLVABLE" << endl;
        return 0;
    }
    int idx = 0;
    for(char c : se){
        mp[c] = idx;
        idx++;
    }

    do{
        if(!check(A) || !check(B) || !check(C)) continue;
        LL Ax = getInt(A);
        LL Bx = getInt(B);
        LL Cx = getInt(C);

        if(Ax + Bx == Cx){
            cout << Ax << endl;
            cout << Bx << endl;
            cout << Cx << endl;
            return 0;
        }
        
    }while(next_permutation(arr, arr+10));


    cout << "UNSOLVABLE" << endl;
}