#include<bits/stdc++.h>
#define int long long
#define REP(i,a,n) for(int i=a;i<(n);i++)
#define REP_sz(i,s) for(int i=0;i<s.size();i++)
#define gcd(a,b) __gcd(a,b)
#define RE return
#define FILL(a,b) memset(a,b,sizeof(a))
#define SO(a) sort(all(a))
#define all(a) a.begin(),a.end()
#define pb push_back
#define sz(a) (int)a.size()
#define V vector
#define ld long double
#define viit(a) vector<int>::iterator a
#define IT iterator
#define SET setprecision
#define FOR(i,a,n) for(int i=a;i<=(n);i++)
#define ER1(a) a.erase(a.begin())
#define ER0(a) a.erase(a.end())
#define pii pair<int,int>
#define pause system("PAUSE")
#define cls system("CLS")
#define mod1 1000000007
#define mod2 998244353
#define infmod 9223372036854775783
#define tc int t;cin>>t;while(t--)solve();
#define over(x) {cout<<x<<endl;return;}
#define intsz(x) (int)sz(to_string(x))
using namespace std;
int n;
bool found[200];
vector<char> v; 
int m[200]; 
string s[20]; 
bool used[20]; 
int ans;
void dfs(int pos){
	if(pos==v.size()){ 
		int sum=0;
		REP(i,0,n){ 
			int now=0;
			if(m[s[i][0]]==0) return; 
			REP(j,0,s[i].size())now=now*10+m[s[i][j]];
			if(i!=n-1)sum+=now;
			else sum-=now;
		}
		if(sum==0){
			REP(i,0,n){
			REP(j,0,s[i].size())
			cout<<m[s[i][j]];
			cout<<endl;
			}
			exit(0);
		}
		return;
	}
	REP(i,0,10)
	if(!used[i]){
		used[i]=1;
		m[v[pos]]=i;
		dfs(pos+1); 
		m[v[pos]]=0; 
		used[i]=0;
	}
}
signed main(){
	n=3;
	REP(i,0,n){
	cin>>s[i];
	REP(j,0,s[i].size())found[s[i][j]]=1;
	}
	for(int i=1;i<127;i++)
	if(found[i]){
		bool flag=1;
		REP(j,0,v.size())
		if(v[j]==i)flag=0;
		if(flag)v.pb(i);
	}
	dfs(0);
	cout<<"UNSOLVABLE";
	return 0;
}
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<tuple>
#include<cstring>

#define REP(i,n) for(int i=0;i<(int)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

#define INF 1000000000

using namespace std;

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

using ll = long long;
using P = pair<int, int>;
using PLL = pair<ll, ll>;

string S1, S2, S3;
vector<char> v;
vector<int> p;

int pos(char c) {

	REP(i, SZ(v)) {
		if (v[i] == c)return i;
	}
	return -1;
}

int main() {

	cin >> S1 >> S2 >> S3;

	REP(i, SZ(S1)) {
		if (find(ALL(v), S1[i]) == v.end()) {
			v.pb(S1[i]);
		}
	}
	REP(i, SZ(S2)) {
		if (find(ALL(v), S2[i]) == v.end()) {
			v.pb(S2[i]);
		}
	}
	REP(i, SZ(S3)) {
		if (find(ALL(v), S3[i]) == v.end()) {
			v.pb(S3[i]);
		}
	}
	sort(ALL(v));

	if (SZ(v) > 10) {
		cout << "UNSOLVABLE" << endl;
		return 0;
	}
	REP(i, 10) {
		p.pb(i);
	}
	do {
		string s1 = "", s2 = "", s3 = "";
		bool cont = false;
		REP(i,SZ(S1)){
			s1 += (char)(p[pos(S1[i])] + '0');
			if (i == 0 && p[pos(S1[i])] == 0) {
				cont = true;
			}
				
		}
		REP(i, SZ(S2)) {
			s2 += (char)(p[pos(S2[i])] + '0');
			if (i == 0 && p[pos(S2[i])] == 0) {
				cont = true;
			}
		}
		REP(i, SZ(S3)) {
			s3 += (char)(p[pos(S3[i])] + '0');
			if (i == 0 && p[pos(S3[i])] == 0) {
				cont = true;
			}
		}
		if (cont)continue;
		ll ss1, ss2, ss3;
		ss1 = stoll(s1);
		ss2 = stoll(s2);
		ss3 = stoll(s3);
		if (ss1 + ss2 == ss3) {
			cout << ss1 << endl << ss2 << endl << ss3 << endl;
			return 0;
		}
	} while (next_permutation(ALL(p)));

	cout << "UNSOLVABLE" << endl;

	return 0;
}