/** I can do this all day **/

#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;

typedef long long                   ll;
typedef long double                 ld;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define SZ(x)			    		(int)x.size()
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);

const int N = 1e6 + 10;
const ll mod = 1e9 + 7;
const ll mod2 = 998244353;
const ll inf = 8e18;
const int LOG = 22;

ll pw(ll a , ll b, ll M)  { return (!b ? 1 : (b & 1 ? (a * pw(a * a % M, b / 2, M)) % M : pw(a * a % M, b / 2, M))); }

int n, A[N];

int main()
{
	scanf("%d", &n);
	A[1] = 6;
	A[2] = 10;
	A[3] = 15;
	int ptr = 16;
	for(int i = 4; i <= n; i ++)
	{
		int ok = 0;
		while(!ok)
		{
			ok = 1;
			for(int j = 1; j < i; j ++)
			{
				if(__gcd(ptr, A[j]) == 1)
				{
					ok = 0;
					break;
				}
			}
			if(!ok)
			{
				ptr ++;
			}
		}
		A[i] = ptr;
		ptr ++;
	}
	for(int i = 1; i <= n; i ++)
	{
		printf("%d ", A[i]);
	}
    return 0;
}

/** test corner cases(n = 1?) watch for overflow or minus indices **/


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

#define ll long long int
#define ull unsigned long long int


/**********************************************/


bool rec(set<char> s, map<char, vector<pair<int, int>>>& mp, vector<string>& num) {
	if (mp.empty()) {
		for (int i = 0; i < 3; i++) {
			if (num[i][0] == '0') return false;
		}

		ll a = stoll(num[0]);
		ll b = stoll(num[1]);
		ll c = stoll(num[2]);

		if (a + b == c) {
			cout << a << endl;
			cout << b << endl;
			cout << c << endl;
			return true;
		} else {
			return false;
		}
	}

	char currentChar = mp.begin()->first;
	auto v = mp.begin()->second;
	mp.erase(currentChar);

	vector<char> v1;
	for (auto& x : s) v1.push_back(x);

	for (auto& x : v1) {
		s.erase(x);
		for (auto& p : v) {
			int stringIndex = p.first;
			int charIndex = p.second;

			num[stringIndex][charIndex] = x;
		}

		if (rec(s, mp, num)) return true;

		s.insert(x);
	}

	mp[currentChar] = v;
	return false;
}

void solve(vector<string>& v) {
	if (v[2].size() < v[0].size() || v[2].size() < v[1].size()) {
		cout << "UNSOLVABLE" << endl;
		return;
	}

	map<char, vector<pair<int, int>>> mp;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < v[i].size(); j++) {
			mp[v[i][j]].push_back({i, j});
		}
	}

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

	vector<string> num(3);
	for (int i = 0; i < 3; i++) {
		num[i] = "";
		for (int j = 0; j < v[i].size(); j++) {
			num[i] += 'x';
		}
	}

	set<char> s;
	for (char i = '0'; i <= '9'; i++) s.insert(i);

	if (!rec(s, mp, num)) {
		cout << "UNSOLVABLE" << endl;
	}
}


int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll t = 1;
	// cin >> t;
	while (t--) {
		vector<string> v(3);
		for (int i = 0; i < 3; i++) {
			cin >> v[i];
		}

		solve(v);
	}
}

