#include <bits/stdc++.h>
using namespace std;

int main(){

    int a,b,c;
    cin >> a >> b >> c;

    if(a==b){
        cout << c << endl;
    }
    else if(b == c){
        cout << a <<endl;
    }
    else if(c == a){
        cout << b << endl;
    }
    else{
        cout << 0 << endl;
    }

    return 0;

}
///Bismillahir Rahmanir Rahim
/*
    Author: Tanzin Ahammad
*/
#include<bits/stdc++.h>
#define        u64             uint64_t
#define        ll              long long
#define        endl            "\n"
#define        PI              acos(-1)
#define        fi              first
#define        si              second
#define        pb              push_back
#define        set0(arr)       memset(arr, 0, sizeof(arr))
#define        setinf(arr)     memset(arr, 126, sizeof(arr))
#define        gcd(a,b)        __gcd(a,b)
#define        lcm(a,b)        (a*b)/gcd(a,b)
#define        all(x)          (x).begin(),(x).end()
#define        sz(v)           ((ll)(v).size())
#define        mem(a,b)        memset(a, b, sizeof(a))
#define        uniq(v)         (v).erase(unique(all(v)),(v).end())
#define        mchk(mask,pos)  (mask & (1ll<<pos))
#define        mset(mask,pos)  (mask bitor (1ll<<pos))
#define        munset(mask,pos) (mask ^ (1ll<<pos))
#define        print_case      cout<<"Case "<<cs<<": "
#define        IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
using          pll        =      pair<ll, ll> ;
using          vl         =      vector<ll> ;
using          vpll       =      vector<pll> ;
using          mll        =      map<ll, ll> ;
using          mcl        =      map<char, ll> ;
using          msl        =      map<string,ll> ;
using          sl         =      set<ll> ;
using          sc         =      set<char> ;
const int N = 1e6+5;
const int mod = (int)  1e9 + 7;
ll arr[N];
ll sumd(ll a,ll b){return (((a%mod)+(b%mod))%mod);}
ll muld(ll a,ll b){return (((a%mod)*(b%mod))%mod);}
ll subd(ll a,ll b){return (((a%mod)-(b%mod)+mod)%mod);}



int main()
{
    IOS;

    ll tc,n,x,i,j;
    string s1,s2,s3;
    cin>>s1>>s2>>s3;
    sc st;
    if(s1==s3)
    {
           cout<<"UNSOLVABLE";
           return 0;
    }
    for(i=0;i<sz(s1);i++)
    {
           st.insert(s1[i]);
    }
    for(i=0;i<sz(s2);i++)
    {
           st.insert(s2[i]);
    }
    for(i=0;i<sz(s3);i++)
    {
           st.insert(s3[i]);
    }
    if(sz(st)>10)
    {
         cout<<"UNSOLVABLE";
    }
    else
    {
           vector<char> vt;
           for(auto pr:st)
           {
                 vt.pb(pr);
           }
           string num="0123456789";
           ll f=0,n1,n2,n3;
           do
           {
                  map<char,ll>mp;
                  for(i=0;i<sz(vt);i++)
                  {
                         mp[vt[i]]=(num[i]-'0');
                  }
                  n1=0,n2=0,n3=0;
                  ll f1=0;
                  for(i=0;i<sz(s1)&&f1==0;i++)
                  {
                         if(i==0&&mp[s1[i]]==0)
                         {
                                f1=1;
                                break;
                         }
                         n1=n1*10+mp[s1[i]];
                  }
                  for(i=0;i<sz(s2)&&f1==0;i++)
                  {
                         if(i==0&&mp[s2[i]]==0)
                         {
                                f1=1;
                                break;
                         }
                         n2=n2*10+mp[s2[i]];
                  }
                  for(i=0;i<sz(s3)&&f1==0;i++)
                  {
                         if(i==0&&mp[s3[i]]==0)
                         {
                                f1=1;
                                break;
                         }
                         n3=n3*10+mp[s3[i]];
                  }

                  if(f1==0&&n1+n2==n3)
                  {
                         f=1;break;
                  }

           }while(next_permutation(num.begin(),num.end()));
           if(f==1)
           {
                  cout<<n1<<endl<<n2<<endl<<n3;
           }
           else cout<<"UNSOLVABLE";
    }






    return 0;
}


