#include "bits/stdc++.h"
//#include "atcoder/all"
using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
//const int INF = 1e9;
//const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define endl "\n"
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	vector<char>cv;
	rep(i, s1.size()) { cv.push_back(s1[i]); }
	rep(i, s2.size()) { cv.push_back(s2[i]); }
	rep(i, s3.size()) { cv.push_back(s3[i]); }
	sort(cv.begin(), cv.end());
	cv.erase(unique(cv.begin(), cv.end()), cv.end());
	if (cv.size() > 10) { cout << "UNSOLVABLE " << endl; return 0; }
	vector<int> v;
	rep(i, 10) { v.push_back(i); }
	map<char, int>mp;
	do {
		int count = 0;
		rep(i, cv.size()) {
			mp[cv[i]] = v[i];
		}
		long long n1 = 0;
		long long n2 = 0;
		long long n3 = 0;
		if (0 == mp[s1[0]]) { continue; }
		if (0 == mp[s2[0]]) { continue; }
		if (0 == mp[s3[0]]) { continue; }
		rep(i, s1.size()) {
			n1 *= 10;
			n1 += mp[s1[i]];
		}
		rep(i, s2.size()) {
			n2 *= 10;
			n2 += mp[s2[i]];
		}
		rep(i, s3.size()) {
			n3 *= 10;
			n3 += mp[s3[i]];
		}
		if (n1 + n2 == n3) {
			cout << n1 << endl;
			cout << n2 << endl;
			cout << n3 << endl;
			return 0;
		}

	} while (next_permutation(v.begin(), v.end()));
	cout << "UNSOLVABLE " << endl;
	return 0;
}
// ----- In the name of ALLAH, the Most Gracious, the Most Merciful -----

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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define deb(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define memo(dp,val) memset(dp,val,sizeof(dp))
#define NINJA ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(a) a.begin(),a.end()
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define dloop(i,n) for(int i=n-1;i>=0;i--)
#define iii tuple<int,int,int>
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define int long long
#define ld long double
#define pb push_back
#define endl "\n"
#define setbits __builtin_popcountll
#define mp map<int,int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007
#define inf (int)1e18

int n;
int dp[205][12];

int solve(int sz, int c){
    if(c==11) return 1;
    if(sz==n || c>11) return 0;

    int&ans = dp[sz][c];

    if(ans!=-1) return ans;

    ans = 0;

    for(int i=sz+1;i<n;i++){
        ans += solve(i,c+1);
    }
    return ans;
} 

int32_t main(){
    NINJA;

    memset(dp,-1,sizeof(dp));

    cin >> n;
    cout << solve(0,0);
    
    return 0;
}