#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  string S[3];
  REP(i,3)cin>>S[i];
  char SF[3];
  REP(i,3)SF[i]=S[i][0];
  REP(i,3)reverse(ALL(S[i]));
  set<char> s;
  REP(i,3)for(auto c:S[i])s.insert(c);
  if(s.size()>10){
    cout<<"UNSOLVABLE"<<endl;
    return 0;
  }
  map<char,int> c;
  int i=0;
  for(auto e:s){
    c[e]=i;
    i++;
  }
  vector<int> v(10);
  REP(i,10)v[i]=i;
  do {
    bool f=false;
    REP(i,3)if(v[c[SF[i]]]==0)f=true;
    if(f)continue;
    lint N[3]={0};
    REP(i,3){
      lint base=1;
      for(auto e:S[i]){
        N[i]+=v[c[e]]*base;
        base*=10;
      }
    }
    if(N[0]+N[1]==N[2]){
      REP(i,3)cout<<N[i]<<endl;
      // for(auto e:c){
      //   cerr<<e.first<<":"<<v[e.second]<<endl;
      // }
      // cerr<<endl;
      return 0;
    }
  } while( next_permutation(v.begin(), v.end()) );     // 次の順列を生成
  cout<<"UNSOLVABLE"<<endl;
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define INF 1000000000000
typedef long long ll;

int main()
{
  int a, b, c, ans = 0;
  cin >> a >> b >> c;
  if (a != b && b != c && c != a)
  {
    cout << 0 << endl;
  }
  else if (a == b)
  {
    cout << c << endl;
  }
  else if (b == c)
  {
    cout << a << endl;
  }
  else
  {
    cout << b << endl;
  }
}