#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007

const ll N = 100000000;

string S[3];
string T;
ll mp[N];

ll g(string S){
	ll ret = 0;
	for(int i = 0; i<S.size(); i++){
		ret*=10;
		ret+=mp[S[i]];
	}
	return ret;
}

bool f(vector<int>  v){
	for(int i = 0; i<T.size(); i++){
		mp[T[i]] = v[i];
	}
	for(int i = 0; i<3; i++){
		if(mp[S[i][0]]==0) return false;
	}
	if(g(S[0])+g(S[1])==g(S[2])){
		cout<<g(S[0])<<'\n'<<g(S[1])<<'\n'<<g(S[2])<<'\n'; return true;
	}
	return false;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	for(int i = 0; i<3; i++){
		cin>>S[i];
		T+=S[i];
	}
	sort(T.begin(), T.end());
	T.erase(unique(T.begin(), T.end()), T.end());
	if(T.size()>10){
		cout<<"UNSOLVABLE\n";
		return 0;
	}
	vector<int> v;
	for(int i = 0; i<10; i++) v.push_back(i);
	do{
		if(f(v)) return 0;
	} while(next_permutation(v.begin(), v.end()));
	cout<<"UNSOLVABLE\n";
	return 0;
}
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <vector>

using namespace std;
using ll = long long;

int main(){
  string S1,S2,S3; cin>>S1>>S2>>S3;
  set<char> se;
  for(auto c:S1) se.insert(c);
  for(auto c:S2) se.insert(c);
  for(auto c:S3) se.insert(c);
  
  if (se.size() > 10){
    cout<<"UNSOLVABLE\n";
    return 0;
  }
  int N = se.size();
  
  map<char,int> mp;
  int idx=0;
  for(auto c:se){
    mp[c] = idx++;
  }
  
  vector<int> v(10);
  for(int i=0; i<10; i++) v[i]=i;
  auto calc = [&](char c){
    return v[mp[c]];
  };
  do{
    if (calc(S1[0])==0||calc(S2[0])==0||calc(S3[0])==0){
      continue;
    }
    ll A=0,B=0,C=0;
    for(int i=0; i<S1.size(); i++){
      A=A*10+calc(S1[i]);
    }
    for(int i=0; i<S2.size(); i++){
      B=B*10+calc(S2[i]);
    }
    for(int i=0; i<S3.size(); i++){
      C=C*10+calc(S3[i]);
    }
    if (A+B==C){
      cout<<A<<endl;
      cout<<B<<endl;
      cout<<C<<endl;
      return 0;
    }
  }while(next_permutation(v.begin(), v.end()));
  cout<<"UNSOLVABLE\n";
  return 0;
}