#include <bits/stdc++.h>

#define SIS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define lowbit(x) (x & -x)
#define FOR(i,a,b)  for(int i=(a); i< (b); ++i)
#define RFOR(i,b,a) for(int i=(b);i>=(a);i--)
#define REP(i,a,b)  for(int i=(a); i<=(b); ++i)
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
template<typename T>
void PrArr(const T a[] , int len){
	for(int i = 0;i <= len; i++)cout << a[i] << " ";
	cout << endl;
}
template<typename T>
void PrVec(const vector<T> a){
	for(auto it : a)cout << it << " ";
	cout << endl;
}
const int MAX = 0x7ffffff;
const int MIN = 0xcf;
int test;
void slove()
{
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;

	// 1. 记录一下每个字符出现的次数
	map<char, int> mp;
	for(char c : s1) mp[c] ++;
	for(char c : s2) mp[c] ++;
	for(char c : s3) mp[c] ++;
	/*
	如果出现的字母数量大于10意味着要出现10个不同数字表示
	这样是不可能成立的，所以这种情况下一定不存在解
	*/
	if(mp.size() > 10) {
		cout << "UNSOLVABLE" << endl;
		return ;
	}

	// 获取到以上出现过哪些字母并组合成一个字符串
	string s0;
	for(auto p : mp) s0 += p.first;
	int m = s0.size();

	vector<int> v(10);
	for(int i = 0; i < 10 ; i++) v[i] = i;


	auto val = [&](char c) {
		for(int i = 0; i < m; i ++)
		{
			if(c == s0[i]) {
				return v[i];
			}
		}
		return -1;
	};

	do {
		// 此时数字包含前导0需要排除这种情况。 
		if(val(s1[0]) == 0 || val(s2[0]) == 0 || val(s3[0]) == 0) {
			continue;
		}

		ll x1 = 0, x2 = 0, x3 = 0;

		for(auto c : s1) {
			x1 *= 10;
			x1 += val(c);
		}

		for(auto c : s2) {
			x2 *= 10;
			x2 += val(c);
		}

		for(auto c : s3) {
			x3 *= 10;
			x3 += val(c);
		}

		if(x1 + x2 == x3)
		{
			cout << x1 << endl;
			cout << x2 << endl;
			cout << x3 << endl;
			return ;
		}
	} while(next_permutation(v.begin(),v.end()));

	cout << "UNSOLVABLE" << endl;
}
int main()
{
#ifdef LOCAL
	auto start_time = clock();
	cerr << setprecision(3) << fixed; // 在iomanip中
#endif
	SIS;slove();
#ifdef LOCAL
	auto end_time = clock();
	cerr << "Execution time: " << (end_time - start_time) * (int)1e3 / CLOCKS_PER_SEC << " ms\n";
#endif
}
#include <bits/stdc++.h>
using namespace std;

#define int int64_t

void __print(int x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template<typename T, typename V>
void __print(const pair<T, V> &x) { cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}'; }
template<typename T>
void __print(const T &x)  { int f = 0; cerr << '{'; for(auto &i: x) cerr << (f++ ? " " : ""), __print(i); cerr << "}"; }
void _print()  { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); }
#ifndef DEBUG
#define imie(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define imie(x...)
#endif

int f(string s)
{
	int ans = 0;
	for(char c : s)
		ans = ans * 10 + c - '0';
	return ans;
}



int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	vector<string> s(3);
	for(auto &x : s)
		cin >> x;

	vector<pair<int, int>> g[26];
	set<int> idx;

	for(int i = 0; i < 3; i++) {
		for(int j = 0; j < int(s[i].size()); j++) {
			idx.insert(s[i][j] - 'a');
			g[s[i][j] - 'a'].push_back(make_pair(i, j));
		}
	}

	int N = int(idx.size());
	if(N > 10) {
		cout << "UNSOLVABLE";
		return 0;
	}

	vector<int> permute(10);
	for(int i = 0; i < 10; i++)
		permute[i] = i;

	do {
		int c = 0;
		for(int idx_in_g : idx) {
			for(auto p : g[idx_in_g])
				s[p.first][p.second] = char(permute[c] + '0');
			c++;
		}

		if(s[0][0] == '0' || s[1][0] == '0' || s[2][0] == '0')
			continue;

		vector<int> num(3);
		for(int i = 0; i < 3; i++) {
			num[i] = f(s[i]);
		}

		if(num[0] + num[1] == num[2]) {
			for(int x : num)
				cout << x << endl;
			return 0;
		}

	} while(next_permutation(permute.begin(), permute.end()));

	cout << "UNSOLVABLE";
	
	
	
	
	return 0;
}