#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll LINF = 1e18;
const int INF = 1e9;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
template <class T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return 1;
  }
  return 0;
}
// Union-Find
struct UnionFind
{
  vector<int> par, siz;

  UnionFind(int n) : par(n, -1), siz(n, 1) {}

  // �������
  int root(int x)
  {
    if (par[x] == -1)
      return x;
    else
      return par[x] = root(par[x]);
  }

  // x �� y ��Ʊ�����롼�פ�°���뤫�ɤ��� (�������פ��뤫�ɤ���)
  bool issame(int x, int y)
  {
    return root(x) == root(y);
  }

  // x ��ޤ॰�롼�פ� y ��ޤ॰�롼�פȤ�ʻ�礹��
  bool unite(int x, int y)
  {
    x = root(x), y = root(y);
    if (x == y)
      return false;
    if (siz[x] < siz[y])
      swap(x, y);
    par[y] = x;
    siz[x] += siz[y];
    return true;
  }

  // x ��ޤ॰�롼�פΥ�����
  int size(int x)
  {
    return siz[root(x)];
  }
};

int main()
{
  ll N;
  cin >> N;
  unordered_map<string, int> a(N);
  vector<string> b(N);
  for (int i = 0; i < N; i++)
  {
    string temp;
    cin >> temp;
    a[temp]=1;
    b[i] = temp;
  }
  for (int i = 0; i < N; i++)
  {
    if(a['!'+b[i]]!=0){
      cout << b[i] << endl;
      return 0;
    }
  }
  cout << "satisfiable" << endl;
}
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less

//using namespace __gnu_pbds;
using namespace std;

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_set;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ii pair<int, int>
#define fi first
#define se second
#define int long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define v1 v<<1
#define v2 (v<<1)|1
//__builtin_popcountll(x) : Number of 1-bit
//__builtin_ctzll(x) : Number of trailing 0
const int inf = (int)1e9;
const int mod = (int)1e9 + 7;
int dx[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int dy[30];
int cal(string s){
	int sum = 0LL;
	for (int i = 0; i < s.size(); i++){
		sum = sum * 10LL + dx[dy[s[i] - 'a']];
	}
	return sum;
}
bool ok(string s){
    return dx[dy[s[0]-'a']]!=0;
}

void print(string s){
    for(int i=0;s[i];i++)putchar(dx[dy[s[i]-'a']]+'0');
    putchar('\n');
}
clock_t t1,t2;

string s[4];
signed main()
{
	// freopen(".inp","r",stdin);
    // freopen(".out","w",stdout);
	fastio
	int cnt = 0, a[30], len[4], b[30];
	cin >> s[1] >> s[2] >> s[3];
	for (int i = 1; i <= 3; i++) len[i] = s[i].size();
	set<int> x;
	for (int i = 1; i <= 3; i++){
		for (int j = 0; j < len[i]; j++){
			x.insert(s[i][j]);
		}
	}
	if(x.size() > 10){
		cout << "UNSOLVABLE";
		return 0;
	}
	for (auto i : x){
		dy[i - 'a'] = cnt;
		cnt++;
	}
//	cout << cal(s[1]) << cal(s[2]) << ok(s[1]) << ok(s[2]);
	do{
		int m = cal(s[1]), m1 = cal(s[2]), m2 = cal(s[3]);
		if(m + m1 == m2 && ok(s[1]) && ok(s[2]) && ok(s[3])){
			print(s[1]);
			print(s[2]);
			print(s[3]);
			return 0;
		}
	}
	while(next_permutation(dx, dx + 10));
	cout << "UNSOLVABLE";
	return 0;
	
}


