#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forin(in) for(ll i=0; i<(ll)in.size(); i++) cin>>in[i]
#define forout(out) for(ll i=0; i<(ll)out.size(); i++) cout<<out[i]<<" "
#define rep(i, n) for(ll i=0; i<(n); i++)
#define rep_up(i, a, n) for (ll i = a; i < n; ++i)
#define rep_down(i, a, n) for (ll i = a; i >= n; --i)
#define P pair<ll, ll>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define vvvll vector<vector<vector<ll>>>
#define vvll vector<vector<ll>>
#define vll vector<ll>
#define pqll priority_queue<ll>
#define pqllg priority_queue<ll, vector<ll>, greater<ll>>
constexpr ll INF = (1ll << 60);
constexpr ll mod = 1000000007;

int main() {
	string s1, s2, s3; 
	vll p = {0,1,2,3,4,5,6,7,8,9};
	set<char> s;
	map<char,int> m;
	vector<char> v;
	cin >> s1 >> s2 >> s3;
	rep(i,s1.size()) s.insert(s1[i]);
	rep(i,s2.size()) s.insert(s2[i]);
	rep(i,s3.size()) s.insert(s3[i]);
	for(auto a:s) v.push_back(a);
	int N = v.size();
	do{
		if(N >= 11) break;

		rep(i,N) {
			m[v[i]] = p[i];
			//cout << v[i] << ":" << p[i] << endl;
		}
		//cout << "------------------" << endl;
		if(m[s1[0]] == 0||m[s2[0]] == 0||m[s3[0]] == 0) continue;
		ll n1 = 0, n2 = 0, n3 = 0;
		rep(i,s1.size()) {
			n1 *= 10;
			n1 += m[s1[i]];
		}
		rep(i,s2.size()) {
			n2 *= 10;
			n2 += m[s2[i]];
		}
		rep(i,s3.size()) {
			n3 *= 10;
			n3 += m[s3[i]];
		}
		if(n1 + n2 == n3) {
			cout << n1 << endl;
			cout << n2 << endl;
			cout << n3 << endl;
			return 0;
		}
	}while(next_permutation(all(p)));
	cout << "UNSOLVABLE" << endl;
}
#include<bits/stdc++.h>
#define err() cout<<"UNSOLVABLE"<<endl,exit(0)
#define N 15
using namespace std;
int tot,a[N],A[N],B[N],C[N];
char t[N];
string s1,s2,s3;
map<char,bool> mp;
map<char,int> rpc;
int main(){
	cin>>s1>>s2>>s3;
	if(s3.size()<max(s1.size(),s2.size()))err();
	for(int i=0;i<s1.size();i++)mp[s1[i]]=1;
	for(int i=0;i<s2.size();i++)mp[s2[i]]=1;
	for(int i=0;i<s3.size();i++)mp[s3[i]]=1;
	if(mp.size()>10)err();
	else{
		for(char i='a';i<='z';i++)
			if(mp[i])t[++tot]=i;
		for(int i=1;i<=10;i++)a[i]=i-1;
		do{
			for(int i=1;i<=tot;i++)rpc[t[i]]=a[i];
			for(int i=0;i<s1.size();i++)A[s1.size()-i]=rpc[s1[i]];
			for(int i=0;i<s2.size();i++)B[s2.size()-i]=rpc[s2[i]];
			for(int i=0;i<s3.size();i++)C[s3.size()-i]=rpc[s3[i]];
			if(!A[s1.size()]||!B[s2.size()]||!C[s3.size()])continue;
			for(int i=1;i<=s3.size()+1;i++)A[i]+=B[i],A[i+1]+=A[i]/10,A[i]%=10;
			bool flag=0;
			for(int i=1;i<=s3.size()+1;i++)if(C[i]!=A[i]){flag=1;break;}
			if(!flag){
				for(int i=0;i<s1.size();i++)cout<<rpc[s1[i]];cout<<endl;
				for(int i=0;i<s2.size();i++)cout<<rpc[s2[i]];cout<<endl;
				for(int i=0;i<s3.size();i++)cout<<rpc[s3[i]];cout<<endl;
				exit(0);
			}
			for(int i=1;i<=s3.size()+1;i++)A[i]=B[i]=C[i]=0;
		}while(next_permutation(a+1,a+1+10));
		err();
	}
	return 0;
}