#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;
int main(){
  vector<string> vec(3);
  for(int i=0; i<3; i++){
    cin >> vec[i];
  }
  map<char,int> M;
  int cnt = 0;
  for(int i=0; i<3; i++){
    for(int j=0; j<vec[i].size(); j++){
      if(!M.count(vec[i][j])){
        M[vec[i][j]] = cnt;
        cnt++;
      }
    }
  }
  if(M.size() > 10){
    cout << "UNSOLVABLE" << endl;
    return 0;
  }
  vector<char> num = {'0','1','2','3','4','5','6','7','8','9'};
  do{
    vector<string> check = vec;
    for(int i=0; i<3; i++){
      for(int j=0; j<vec[i].size(); j++){
        check[i][j] = num[M[vec[i][j]]];
      }
    }
    if(check[0][0] == '0' || check[1][0] == '0' || check[2][0] == '0'){
      continue;
    }
    int64_t A = stoll(check[0]);
    int64_t B = stoll(check[1]);
    int64_t C = stoll(check[2]);
    if(A + B == C){
      cout << A << endl;
      cout << B << endl;
      cout << C << endl;
      return 0;
    }
  }while(next_permutation(num.begin(),num.end()));
  cout << "UNSOLVABLE" << endl;
}