#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define x first
#define y second
#define FOR(i, m, n) for (ll i(m); i < n; i++)
#define DWN(i, m, n) for (ll i(m); i >= n; i--)
#define REP(i, n) FOR(i, 0, n)
#define DW(i, n) DWN(i, n, 0)
#define F(n) REP(i, n)
#define FF(n) REP(j, n)
#define D(n) DW(i, n)
#define DD(n) DW(j, n)
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using tll = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vpll = vector<pll>;
using vtll = vector<tll>;
using gr = vector<vll>;
using wgr = vector<vpll>;
void add_edge(gr&g,ll x, ll y){ g[x].pb(y);g[y].pb(x); }
void add_edge(wgr&g,ll x, ll y, ll z){ g[x].eb(y,z);g[y].eb(x,z); }
template<typename T,typename U>
ostream& operator<<(ostream& os, const pair<T,U>& p) { 
    cerr << ' ' <<  p.x << ',' << p.y; return os; }
template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) { 
    for(auto x: v) os << ' ' <<  x; return os; }
template <typename T> 
ostream& operator<<(ostream& os, const set<T>& v) { 
    for(auto x: v) os << ' ' <<  x; return os; }
template<typename T,typename U>
ostream& operator<<(ostream& os, const map<T,U>& v) { 
    for(auto x: v) os << ' ' <<  x; return os; }
struct d_ {
    template<typename T> d_& operator,(const T& x) {
        cerr << ' ' <<  x; return *this;}
} d_t;
#define dbg(args ...) { d_t,"|",__LINE__,"|",":",args,"\n"; }
#define deb(X ...) dbg(#X, "=", X);
#define EPS (1e-10)
#define INF (1LL<<61)
#define YES(x) cout << (x ? "YES" : "NO") << endl;
#define CL(A,I) (memset(A,I,sizeof(A)))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

string s[3];
ll n[3];
int main(void) {
    ios_base::sync_with_stdio(false);
    set<char> ch;
    F(3) cin >> s[i];
    F(3) for(auto c: s[i]) ch.insert(c);
    bool ok = 1;
    if(ch.size()>10) ok=0;
    ll x=0;
    while(ch.size()<10) { ch.insert('A'+x); x++; }
    vector<char> v(all(ch));
    sort(all(v));
    if(ok) do {
        ok=0;
        F(3) {
            n[i]=0;
            for(auto c: s[i]) {
                ll cur;
                FF(10) if(c==v[j]) cur=j;
                n[i] = 10*n[i]+cur;
            }
        }
        bool cok = 1;
        F(3) cok &= to_string(n[i]).size()==s[i].size() && n[i]!=0;
        if(cok && n[0]+n[1]==n[2]) {
            ok=1;
            F(3) cout << n[i] << endl;
            break;
        }
    } while(next_permutation(all(v)));
    if(!ok) cout << "UNSOLVABLE" << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
// using namespace atcoder;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define gcd __gcd
#define int long long
#define double long double
const int INF = 1e18, MOD = 1e9 + 7;
int pow(int x, int n) {
    return n < 1 ? 1 : pow(x * x, n / 2) * (n % 2 ? x : 1);
}
int modinv(int a) {
    int b = MOD, u = 1, v = 0;
    while (b) {
        int t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= MOD; 
    if (u < 0) u += MOD;
    return u;
}
map<int, int> factorization(int n) {
    map<int, int> res;
    for(int i = 2; i * i <= n; i++) {
        if(i > 3) i++;
        while(!(n % i)) res[i]++, n /= i;
    }
    if(n > 1) res[n]++;
    return res;
}
vector<int> divisors(int n) {
    vector<int> res;
    for (int i = 1; i * i <= n; i++) {
        if(!(n % i)) {
            res.push_back(i);
            if(i * i < n) res.push_back(n / i);
        }
    }
    return res;
}
int combination(int n, int r) {
    int res = 1;
    for(int i = 1; i < r + 1; i++) {
        res *= n--, res /= i;
    }
    return res;
}
bool is_prime(int n) {
    if (n < 2) return false;
    for(int i = 2; i * i <= n; i++) {
        if(i > 3) i++;
        if(!(n % i)) return false;
    }
    return true;
}
signed main() {
    INCANT;
    string s1, s2, s3;
    set<char> list;
    cin>>s1>>s2>>s3;
    reverse(s1.begin(), s1.end());
    reverse(s2.begin(), s2.end());
    reverse(s3.begin(), s3.end());
    for (char c: s1 + s2 + s3) {
        list.insert(c);
    }

    int digits[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
    int x, y, z, i;
    map<char, int> m;
    do {
        m.clear();
        x = y = z = i = 0;
        for (char c: list) {
            m[c] = digits[i++];
        }

        if (
            0 == m[s1[s1.size() - 1]] ||
            0 == m[s2[s2.size() - 1]] ||
            0 == m[s3[s3.size() - 1]]
        ) {
            continue;
        }

        i = 1;
        for (char c: s1) {
            x += i * m[c];
            i *= 10;
        }

        i = 1;
        for (char c: s2) {
            y += i * m[c];
            i *= 10;
        }

        i = 1;
        for (char c: s3) {
            z += i * m[c];
            i *= 10;
        }

        if (z == x + y) {
            cout<<x<<endl<<y<<endl<<z<<endl;
            return 0;
        }
    } while (next_permutation(digits, digits + 10));
    cout<<"UNSOLVABLE"<<endl;
}