#include <bits/stdc++.h>

using namespace std;

#define int long long int

#define rep(i, n) for(int i = 0; i < (int) n; i++)
#define repd(i, n) for(int i = (int) (n - 1); i >= 0; i--)
#define FOR(i, a, b) for(int i = a; i <= (int) b; i++)
#define FORD(i, a, b) for(int i = a; i >= (int) b; i--)

template<typename T>
void load(int n, vector<T> &v) {
  rep(i, n) {
    T a;
    cin >> a;
    v.push_back(a);
  }
}

/// x * y = nとなるような正の整数(x, y)の組
vector<pair<int, int>> pair_of_divisor(int n) {
  vector<pair<int, int>> v;
  for(int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      v.emplace_back(i, n / i);
    }
  }
  return v;
}

signed main() {
  int s, p;
  cin >> s >> p;

  const auto d = pair_of_divisor(p);
  bool canMake = false;
  for (auto pair : d) {
    if (pair.first + pair.second == s) {
      canMake = true;
    }
  }
  if (canMake) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define pb push_back
#define eb emplace_back
#define Field(T) vector<vector<T>>
#define pq(T) priority_queue<T,vector<T>,greater<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  vector<string> s(3);
  rep(i,0,3) cin >> s[i];
  map<char, int> mp;
  rep(i,0,3) {
    for (auto c : s[i]) {
      mp[c] = 1;
    }
  }
  if (len(mp) > 10) {
    cout << "UNSOLVABLE" << endl;
    return 0;
  }
  vector<int> v(10);
  rep(i,0,10) v[i] = i;
  vector<ll> ns(3);
  int idx = 0;
  do {
    ns[0] = ns[1] = ns[2] = 0;
    idx = 0;
    for (auto &p : mp) {
      p.se = v[idx];
      ++idx;
    }
    bool ng = false;
    rep(i,0,3) {
      if (mp[s[i][0]] == 0 && len(s[i]) != 1) {
        ng = true;
        break;
      }
      for (auto c : s[i]) {
        ns[i] *= 10;
        ns[i] += mp[c];
      }
      if (ns[i] == 0) {
		ng = true;
        break;
      }
    }
    if (ng) continue;
    if (ns[0] + ns[1] == ns[2]) {
      printf("%lld\n%lld\n%lld\n", ns[0], ns[1], ns[2]);
      return 0;
    }
  } while(next_permutation(all(v)));
  cout << "UNSOLVABLE" << endl;
  return 0;
}