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


void solveOne()
{
    vector<string> strings(3);
    for(int i = 0; i < 3; i++)
        cin >> strings[i];

    set<char> letters;

    for(int i = 0; i < 3; i++)
    {
        for(int j = 0; j < strings[i].length(); j++)
        {
            letters.insert(strings[i][j]);
        }
    }

    if(letters.size() > 10)
    {
        cout << "UNSOLVABLE\n";
        return;
    }

    // translate to first 10 digits in alphabet
    char nc = '0';
    for(char c : letters)
    {
        for(int i = 0; i < 3; i++)
        {
            replace(strings[i].begin(), strings[i].end(), c, nc);
        }
        nc++;   
    }

    int n = letters.size();
    vector<int> values(n);

    vector<int> numbers(10);
    for(int i = 0; i < 10; i++)
        numbers[i] = i;

    vector<string> resultstrings(3);
    for(int i = 0; i < 3; i++)
        resultstrings[i] = strings[i];

    do
    {
        for(int i = 0; i < n; i++)
        {
            values[i] = numbers[i];
        }

        for(int i = 0; i < 3; i++)
        {
            for(int j = 0; j < strings[i].size(); j++)
            {
                resultstrings[i][j] = '0' + values[strings[i][j] - '0'];
            }
        }

        bool flag = true;
        for(int i = 0; i < 3; i++)
        {
            if(resultstrings[i][0] == '0')
                flag = false;
        }

        if(!flag)
            continue;

        if(stoll(resultstrings[0]) + stoll(resultstrings[1]) == stoll(resultstrings[2]))
        {
            cout << resultstrings[0] << '\n';
            cout << resultstrings[1] << '\n';
            cout << resultstrings[2] << '\n';
            return;
        }

    } while(next_permutation(numbers.begin(), numbers.end()));

    cout << "UNSOLVABLE\n";
}


void setupIo()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);


    #ifndef ONLINE_JUDGE 

    // For getting input from input.txt file 
    freopen("input.txt", "r", stdin); 

    // Printing the Output to output.txt file 
    freopen("output.txt", "w", stdout); 

    #endif 
}

int main()
{
    setupIo();

    int tc;
    //cin >> tc;
    tc = 1;
    while(tc--)
        solveOne();

    return 0;
}
/*
  Author     : MatsuTaku
  Date         : 03/21/21
  Certificate:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDF9T447OEo8XSQ6O1AznN5tKC8mzvYc4Zs3+oOKfMqgLXfOwQnpfcoxKs4MAP1eICBD13PkcIezJ9IlV6nKQZKs1BQmvjSXJ+zKK8YCKvAueNPuNO0Bim43IBaNHNFWcMvcmUvHgRb6hUSO0V8I7OsjiFo20KDBj3gAznu9tir0Q== CompetitiveProgrammingCertification:tkm.matsumoto@gmail.com
*/

#include <bits/stdc++.h>
using namespace std;
#include <x86intrin.h>
#define REP(i, f, n)      for (auto i = (f), i##_len = (n); i < i##_len; i++)
#define rep(i, n)         REP(i, (int) 0, n)
#define RREP(i, f, n)     for (auto i = (n)-1, i##_left = (f); i >= i##_left; i--)
#define rrep(i, n)        RREP(i, (int) 0, n)
using lint = long long int;
using ulint = unsigned long long int;
template<typename T>
using vvec = vector<vector<T>>;
template<typename T>
vvec<T> make_vvec(int n, int m, T v) { return vvec<T>(n, vector<T>(m, v)); }
template<typename T>
T& chmax(T& dst, T x) { return dst = max(dst, x); }
template<typename T>
T& chmin(T& dst, T x) { return dst = min(dst, x); }

class Solver {
 public:
  Solver();
  void solve();
};

Solver::Solver() {}

struct Mex {
  unordered_set<int> s;
  int mex = 1;
  void insert(int x) {
    s.insert(x);
    if (mex == x) {
      ++mex;
      while (s.count(mex))
        ++mex;
    }
  }
};

void Solver::solve() {
  int n; cin>>n;
  vector<int> A(n);
  vector<Mex> M(n);
  REP(m, 2, n+1) {
    A[m-1] = M[m-1].mex;
    for (int j = m*2; j-1 < n; j += m) {
      M[j-1].insert(A[m-1]);
    }
  }
  A[0] = *max_element(A.begin(), A.end()) + 1;
  for (auto a:A)
    cout<<a<<' ';
  cout<<endl;
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  Solver solver;
  int t = 1;
//  cin>>t;
  while (t--) {
    solver.solve();
  }
  return 0;
}
