#include <iostream>
using namespace std;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b && b!=c){
    cout<<c;
  }
  if(a==c && c!=b){
    cout<<b;
  }
  if(b==c && c!=a){
    cout<<a;
  }
  if(a==b && b==c){
    cout<<a;
  }
  if(a!=b && b!=c && c!=a){
    cout<<0;
  }
}
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi; 
typedef pair<ll,ll> pi;
 
#define forn(i,x,n) for(long long int i = x; i < n; ++i)
# define pb push_back
# define mp make_pair

  
struct node
{
    char c;
    ll v;
};
 
vector<ll> variable_list(10);


ll find_num(string a, ll count, node* my_struct){
    ll i=0,m=1,j;
    ll val=0;
    for (i = a.length() - 1; i >= 0; i--)
    {
        char ch = a[i];
        for (j = 0; j < count; j++)
            if (my_struct[j].c == ch)
                break;
  
        val += m * my_struct[j].v;
        m *= 10;
    }
    return val;
}
ll sum_check(node* my_struct, const ll count, string s1, string s2, string s3){
    ll val1 = find_num(s1, count, my_struct);
    ll val2 = find_num(s2, count, my_struct);
    ll val3 = find_num(s3, count, my_struct);
    if (val3 == (val1 + val2)) return 1;
    return 0;
}
  
bool permute_string(const ll count, node* my_struct, ll n, string s1, string s2, string s3)
{
    if (n == count - 1) {  
        forn(i,0,10) {
            if (variable_list[i] == 0) {
  
                if(i==0 && (my_struct[n].c == s1[0] || my_struct[n].c == s2[0] || my_struct[n].c == s3[0] )){continue;}
                my_struct[n].v = i;
  
                if (sum_check(my_struct, count, s1, s2, s3) == 1)
                {
                    map <char,ll> m;
                    for (ll j = 0; j < count; j++){
                        m[my_struct[j].c] = my_struct[j].v;
                    }

                    forn(i,0,s1.length()) cout<< m[s1[i]];
                    cout<<endl;
                    forn(i,0,s2.length()) cout<< m[s2[i]];
                    cout<<endl;
                    forn(i,0,s3.length()) cout<< m[s3[i]];
                    cout<<endl;
                    return true;
                }
            }
        }
        return false;
    }
  
    forn(i,0,10)
    {
        if (variable_list[i] == 0)
        {
  
            if(i==0 && (my_struct[n].c == s1[0] || my_struct[n].c == s2[0] || my_struct[n].c == s3[0] )){continue;}
            my_struct[n].v = i;
            variable_list[i] = 1;
  
            if (permute_string(count, my_struct, n + 1, s1, s2, s3))
                return true;
  
            variable_list[i] = 0;
        }
    }
    return false;
}
  
bool alphametic(string s1, string s2, string s3)
{
    vector<ll> freq(26);
    ll count = 0;
    ll l1 = s1.length();
    ll l2 = s2.length();
    ll l3 = s3.length();
        
    forn(i,0,s1.length()) freq[s1[i] - 'a']++;
    forn(i,0,s2.length()) freq[s2[i] - 'a']++;
    forn(i,0,s3.length()) freq[s3[i] - 'a']++;

 
    forn(i,0,26) if (freq[i] > 0) count++;
  
    if (count > 10) return 0;
  
    node my_struct[count];
    ll j=0;
    forn(i,0,26) {
        if (freq[i] > 0) {
            my_struct[j].c = char(i + 'a'); j++;
        }
    }
    return permute_string(count, my_struct, 0, s1, s2, s3);
}

int main(){
    string a,b,c;
    cin>>a>>b>>c;
    if (!alphametic(a, b, c))
        cout << "UNSOLVABLE"<<endl;
    return 0;
}