#include <bits/stdc++.h>

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 60;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S[3]; cin >> S[0] >> S[1] >> S[2];
    map<char, int> mp;
    int idx = 0;
    rep(i, 3){
        rep(j, S[i].length()){
            if(!mp.count(S[i][j])){
                mp[S[i][j]] = idx;
                idx++;
            }
        }
    }
    if(mp.size() > 10) cout << "UNSOLVABLE" << endl;
    else{
        vector<int> vec(10, 0);
        rep(i, 10) vec[i] = i;
        do{
            bool cont = true;
            ll v[3];
            rep(i, 3){
                string val = "";
                rep(j, S[i].length()){
                    val += ('0' + vec[mp[S[i][j]]]);
                }
                if(val[0] == '0'){
                    cont = false;
                    break;
                }
                v[i] = stoll(val);
            }
            if(cont){
                if(v[0] + v[1] == v[2]){
                    cout << v[0] << endl;
                    cout << v[1] << endl;
                    cout << v[2] << endl;
                    return 0;
                }
            }
        }while(next_permutation(vec.begin(), vec.end()));
        cout << "UNSOLVABLE" << endl;
    }
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (ll i = s; i < e; i++)
#define rrep(i, s, e) for (ll i = s; i > e; i--)

int main() {
  ll A, B, W;
  cin >> A >> B >> W;
  W *= 1000;
  ll cnt_a = W / A, cnt_b = W / B;
  if (cnt_a != cnt_b) cout << cnt_b + (W % B != 0) << " " << cnt_a;
  else if ((W % A) * (W % B) == 0) cout << cnt_a << " " << cnt_a;
  else cout << "UNSATISFIABLE";
}
