#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#include<queue>
#include<cstdio>
#include<vector>
#include <algorithm>
#include<map>
#define rep(i,n) for (int i=0;i<(n);++i)
using ll = long long;
using namespace std;
using P = pair<int,int>;
#define INF 1000000000

int main(){
	map<char,ll> mp;
	vector<string> s(3);
	set<char> head;
	rep(i,3) cin>>s[i];

	rep(i,3){
		reverse(s[i].begin(),s[i].end());
		ll co = 1;
		if(i == 2) co = -1;
		for(char c : s[i]){
			mp[c] += co;
			co *= 10;
		}
		reverse(s[i].begin(),s[i].end());
		head.insert(s[i][0]);
	}
	if(mp.size() > 10){
		cout<<"UNSOLVABLE"<<endl;
		return 0;
	}
	vector<int> p(10);
	iota(p.begin(),p.end(),0);
	do{
		int i = 0;
		ll tot = 0;
		for(auto x:mp){
			char c = x.first;
			ll co = x.second;
			if(p[i] == 0 && head.count(c)) tot = 1e18;
			tot += co*p[i];
			++i;
		}
		if(tot == 0){
			i = 0;
			for(auto& x:mp){
				x.second = p[i];
				++i;
			}
			rep(i,3){
				ll k = 0;
				for(char c : s[i]){
					k = k*10 + mp[c];
				}
				cout<<k<<endl;
			}
			return 0;
		}
	}while(next_permutation(p.begin(),p.end()));
	cout<<"UNSOLVABLE"<<endl;
	return 0;
}
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define pb push_back
#define INF 1000000000
#define LL_MAX 1000000000000000000
#define LL_MIN -1000000000000000000
#define mod 1000000007
#define mod2 998244353
#define PI 3.14159265358979323846264338327950288419716939937510
#define ll int64_t
#define ld long double
#define vi vector <int>
#define vb vector<bool>
#define vvi vector <vector<int>>
#define vll vector<ll>
#define vvl vector <vector<ll>>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pair<int,int>>
#define pld pair<ld,ld>
#define vpll vector<pair<ll,ll>>
#define vpld vector<pair<ld,ld>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define sz(a) (int)a.size()
#define FIO   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fs(x) fixed<<setprecision(x)
#define print(a) {for(auto x:a){cout << x << " ";}}
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// template <typename T>
// using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

bool chmin(ll& a, const ll& b) {
	return b < a ? a = b, 1 : 0;
}
bool chmax(ll& a, const ll& b) {
	return a < b ? a = b, 1 : 0;
}
constexpr int pct(int x) { return __builtin_popcount(x); }
constexpr int bits(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))

const int N = 1e7;

void run_case() {
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	map<char, int> mp;
	for (char c : s1) mp[c]++;
	for (char c : s2) mp[c]++;
	for (char c : s3) mp[c]++;
	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;
	};
	while (next_permutation(all(v))) {
		if (val(s1[0]) == 0 || val(s2[0]) == 0 || val(s3[0]) == 0)continue;
		ll x1 = 0, x2 = 0, x3 = 0;
		for (auto x : s1) {
			x1 *= 10;
			x1 += val(x);
		}
		for (auto x : s2) {
			x2 *= 10;
			x2 += val(x);
		}
		for (auto x : s3) {
			x3 *= 10;
			x3 += val(x);
		}
		if (x1 + x2 == x3) {
			cout << x1 << endl;
			cout << x2 << endl;
			cout << x3 << endl;
			return;
		}
	}
	cout << "UNSOLVABLE\n";
}
auto clk = clock();
int main()
{

	FIO
#ifndef ONLINE_JUDGE
	//for getting input from input.txt
	freopen("input.txt", "r", stdin);
	//for writting output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	int t;
	//cin >> t;
	t = 1;
	while (t--) {
		run_case();
	}
// #ifndef ONLINE_JUDGE
// 	cout << endl
// 	     << "Time elapsed: " << fs(10) << (double)(clock() - clk) / CLOCKS_PER_SEC << endl
// 	     << endl;
// #endif
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * in case of segmentation fault check for ex- a variable declared more than once , or index becoming negative
    * check TLE due to not clearing adjacency list for each test
    * do smth instead of nothing and stay organized
    * BELIEVE in yourself
*/