#include<bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rrep(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr ll INF = 1LL << 30;
constexpr ll mod = 100000; //(ll)1e9 + 7;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
inline void init() {
    cin.tie(nullptr); cout.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
}

map<char, int>mp; 
string s[3];
bool rec(vector<int>v,int index=0) {
    if (index == mp.size()) {
        ll N[3] = { 0 };
        rep(i, 0, 2) {
            rep(j, 0, s[i].size()) {
                if (j == 0 && v[mp[s[i][j]]] == 0)return false;
                N[i] *= 10;
                N[i] += v[mp[s[i][j]]];
            }
        }
        N[2] = N[0] + N[1];
        ll  n = N[2];
        rrep(i, 0, s[2].size()) {
            if (v[mp[s[2][i]]] != (n % 10))return false;
            n /= 10;
        }
        if (n != 0)return false;
        rep(i, 0, 3)cout << N[i] << "\n";
        return true;
    }

    vector<bool>ok(10, true);
    rep(i, 0, v.size())if (v[i] > -1)ok[v[i]] = false;
    rep(i, 0, 10) {
        if (!ok[i])continue;
        v[index] = i;
        if (rec(v, index + 1))return true;
        v[index] = -1;
    }
    return false;
}
int main() {
    init();

   
    set<char>st;
    int index = 0;
    rep(i, 0, 3)cin >> s[i];
    rep(i, 0, 3)rep(j, 0, s[i].size())st.insert(s[i][j]);
    for (auto s : st) {
        mp[s] = index;
        index++;
    }
    if (st.size() > 10) {
        cout << "UNSOLVABLE" << "\n";
        return 0;
    }

    vector<int>v(mp.size(), -1);
    if(!rec(v)) {
        cout << "UNSOLVABLE" << "\n";
        return 0;
    }

    return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define MOD 1000000007

vector<string> s(3), ss(3);
vector<bool> word(26, false), yet(10, false);
vector<int> n(26);

void dfs(int x) {
	if(x == 26) {
		ss[0] = ss[1] = ss[2] = "";
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j < s[i].size(); j++) {
				ss[i] += n[s[i][j] - 'a'] + '0';
			}
		}
		if(ss[0][0] == '0' || ss[1][0] == '0' || ss[2][0] == '0') return;
		if(stoll(ss[0]) + stoll(ss[1]) == stoll(ss[2])) {
			cout << ss[0] << endl << ss[1] << endl << ss[2] << endl;
			exit(0);
		}
		return;
	}
	if(!word[x]){dfs(x+1);return;}
	for(int i = 0; i < 10; i++) {
		if(yet[i]) continue;
		n[x] = i;
		yet[i] = true;
		dfs(x + 1);
		yet[i] = false;
	}
}

int main() {
	cin >> s[0] >> s[1] >> s[2];
	for(int i = 0; i < 3; i++) {
		for(int j = 0; j < s[i].size(); j++) {
			word[s[i][j] - 'a'] = true;
		}
	}
	for(int i = 0; i < 26; i++) {
		if(word[i]) {
			dfs(i);
			break;
		}
	}
	puts("UNSOLVABLE");
	return 0;
}