#include <bits/stdc++.h>

using namespace std;

int main(){
    vector<string> S(3);
    for (auto &s: S)
        cin >> s;

    string C = "";
    for (const auto &s: S)
        C += s;

    sort(C.begin(), C.end());
    C.erase(unique(C.begin(), C.end()), C.end());
    
    if (C.size() > 10){
        puts("UNSOLVABLE");
        return 0;
    }

    vector<char> A;
    for (int i = 0; i < 10; i++)
        A.push_back('0' + i);

    do {
        vector<string> T = S;
        unordered_map<char, char> f;
        for (int i = 0; i < C.size(); i++)
            f[C[i]] = A[i];
        
        for (int i = 0; i < 3; i++){
            for (auto &t: T[i])
                t = f[t];
        }

        vector<int64_t> B(3);
        bool flag = true;
        for (int i = 0; i < 3; i++){
            B[i] = stoll(T[i]);
            flag &= T[i] == to_string(B[i]);
            flag &= B[i] > 0;
        }

        if (!flag)
            continue;

        if (B[0] + B[1] == B[2]){
            for (const auto &b: B)
                cout << b << endl;
            return 0;
        }
    } while (next_permutation(A.begin(), A.end()));

    puts("UNSOLVABLE");
}
#include <bits/stdc++.h>
using namespace std;

#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()
#define RALL(a)     (a).rbegin(),(a).rend()
#define PRINT(a)   cout << (a) << endl

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

bool check(vector<string> &s, map<char,int> &cnv, set<char> &head){
  
  REP(i,3)if(cnv[s[i][0]] == 0)return false;

  ll s1=0;
  ll s2=0;
  ll s3=0;
  for(auto c: s[0]){
    s1 *= 10;
    s1 += cnv[c];
  }
  for(auto c: s[1]){
    s2 *= 10;
    s2 += cnv[c];
  }
  for(auto c: s[2]){
    s3 *= 10;
    s3 += cnv[c];
  }

  if(s1+s2==s3){
    cout << s1 << " " << s2 << " " << s3 << endl;
    return true;
  }

  return false;
}


int main(){
  vector<string> s(3);
  REP(i,3)cin >> s[i];

  set<char> head;
  head.insert(s[0][0]);
  head.insert(s[1][0]);
  head.insert(s[2][0]);    

  map<char,int> mp;
  REP(i,3){
    for(auto c: s[i])mp[c]++;
  }

  if(mp.size() > 10){
    cout << "UNSOLVABLE" << endl;
    return 0;
  }

  vi p(10);
  REP(i,10)p[i]=i;

  do{
    int i=0;
    map<char,int> cnv;
    for(auto v: mp){
      cnv[v.first] = p[i++];
    }
    if(check(s,cnv,head))return 0;

  }while(next_permutation(ALL(p)));

  cout << "UNSOLVABLE" << endl;
}

