#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string s[3];
map<char,int>bj;
map<char,int>num;
int a[12]={0}; 
char c[12]={0};
int n=0,ok=0;
ll x[3];
void solve(int k){
	//cout<<k<<endl;
	if(k==n){
		for(int i=0;i<3;i++){
			x[i]=0;
			for(int j=0;j<s[i].size();j++){
				x[i]=x[i]*10+num[s[i][j]];
			} 
		}
		//cout<<x[0]<<endl<<x[1]<<endl<<x[2]<<endl;
		if(x[0]+x[1]==x[2]&&x[0]&&x[1]&&x[2]&&num[s[0][0]]&&num[s[1][0]]&&num[s[2][0]])ok=1;
		return ;
	}
	int i=0;
	for(;i<10&&!ok;i++){
		if(!a[i]){
			a[i]=1;
			num[c[k]]=i;
			solve(k+1);
			a[i]=0;
		}
	}
}
int main()
{
	for(int i=0;i<3;i++){
		cin>>s[i];
		for(int j=0;j<s[i].size();j++){
			if(!bj[s[i][j]]){
				c[n++]=s[i][j];
				bj[s[i][j]]=1;
			}
		}
	}
	//cout<<n<<endl;
	solve(0);
	if(ok)cout<<x[0]<<endl<<x[1]<<endl<<x[2]<<endl;
	else cout<<"UNSOLVABLE"<<endl;
//	for(int i=0;i<n;i++){
//		cout<<c[i]<<" "<<num[c[i]]<<endl;
//	}
	return 0;
}
#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;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef vector<pll> vll;
typedef vector<vl> vvl;

#define fori(i, n) for (int i = 0; i < n; i++)
#define ford(i, n) for (int i = n - 1; i >= 0; i--)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
#define trav(x, a) for (auto &x : a)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define endl '\n'
#define sz(a) (int)(a).size()
#define fi first
#define se second

clock_t time_p = clock();
void time_taken()
{
    time_p = clock() - time_p;
    cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}

const ll mod = 1e9 + 7;
const ll INF = 1e18;

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(nullptr);

    string s;
    cin >> s;
    int n = sz(s);
    bool ok = 1;
    fori(i, n){
        ok &= ((s[i] >= 'a' and s[i] <= 'z' and i % 2 == 0) or (s[i] >= 'A' and s[i] <= 'Z' and i%2==1));
    }

    cout << (ok ? "Yes" : "No") << endl;

    time_taken();
    return 0;
}