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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define all(a) (a).begin(),(a).end()
#define ODD(x) ( ((x)&1)==0?0:1 )
#define SIGN(x) ( ((x) > 0) - ((x) < 0)  )
#define dbg(x) cerr << #x"= " << x << endl

std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}

#define NO "UNSOLVABLE\n"
string s[3];
int mp[27];
bool used[10];
int sz[3];

void solve(int idx,int carry=0){
    FOR(i,3) {
        if (idx == sz[i] - 1 && mp[s[i][idx] - 'a'] == 0) return;
    }
    if (idx==sz[2]){
        if (carry) return;
        FOR(i,3){
            reverse(all(s[i]));
            for(char c:s[i]){
                int d = c-'a';
                if (d==26) continue;
                cout << mp[d];
            }
            cout << '\n';
        }
        exit(0);
    }
    FOR(i,3) {
        if (mp[s[i][idx] - 'a'] == -1) {
            FOR(j, 10) {
                if (used[j]) continue;
                mp[s[i][idx] - 'a'] = j;
                used[j]=1;
                solve(idx, carry);
                used[j]=0;
            }
            mp[s[i][idx] - 'a'] = -1;
            return;
        }
    }
    int num = mp[s[0][idx]-'a']+mp[s[1][idx]-'a']+carry;
    int d = num%10;
    if (d!=mp[s[2][idx]-'a']) return;
    solve(idx+1,num/10);
}

int main() {
    READ(0);
    FOR(i,3) {cin>>s[i];sz[i]=s[i].size();}
    if (sz[2] < max(sz[0],sz[1])) {cout << NO;return 0;}
    if (sz[2] > max(sz[0],sz[1])+1) {cout << NO;return 0;}
    FOR(i,3) reverse(all(s[i]));
    FOR(i,2) while(s[i].size()<s[2].size()) s[i] += char('z'+1);
    memset(mp,-1,sizeof(mp));
    mp[26]=0;
    solve(0);
    cout << NO;

    return 0;
}


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

vector<int> check;
string get(string s){
	string n="";
	for (char&c:s){
		n.push_back(check[c-'a']+'0');
	}
	return n;
}
int main(){
	string s1,s2,s3;cin>>s1>>s2>>s3;
	check.assign(26,-1);
	for (char&c:s1) check[c-'a']=1;
	for (char&c:s2) check[c-'a']=1;
	for (char&c:s3) check[c-'a']=1;

	int cnt=0;for(int &v:check) cnt+=(v==1);
	if (cnt>10) {
		cout<<"UNSOLVABLE\n";
		return 0;
	}
	queue<vector<int>> q;
	q.push(vector<int>());
	while (q.front().size()<cnt){
		vector<int> v=q.front();
		q.pop();
		vector<bool> inside(10);
		for (int i:v) inside[i]=true;
		v.push_back(0);
		for (int i=0;i<10;++i){
			if (inside[i]) continue;
			v.back()=i;
			q.push(v);
		}
	}
	while (!q.empty()){
		vector<int> v=q.front();
		q.pop();
		int cur=0;
		for (int i=0;i<26;++i){
			if (check[i]!=-1) check[i]=v[cur++];
		}
		string n1=get(s1),n2=get(s2),n3=get(s3);
		if (n1[0]!='0'&&n2[0]!='0'&&n3[0]!='0'){
			long long z1=stoll(n1),z2=stoll(n2),z3=stoll(n3);
			if (z1+z2==z3){
				cout<<z1<<'\n';
				cout<<z2<<'\n';
				cout<<z3<<'\n';
				return 0;
			}
		}
	}
	cout<<"UNSOLVABLE\n";
	return 0;
}