#include <bits/stdc++.h>
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define db4(x,y,z,w) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<#w<<"="<<w<<'\n'
#define vll vector< ll >
//#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define pii pair<int,int>
#define vec(a) vector<a >
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
//#define int unsigned long long
//#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long  
#define int long long
using namespace std;
//using ll = unsigned long long;
ll md=MD;
//ll M=1073741824;
ll M=1e9+7;
//ll exp(ll a,ll b){ll r=1;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b>>=1;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll Min(int a,int b){if(a<b)return a; return b;}
ll Max(int a,int b){if(a>b)return a; return b;}
ll powM(ll a,ll b){if(a==1) return 1;ll ans=1;while(b>0){if(b&1)ans=(ans*a)%M;a=(a*a)%M;b=b>>1;}return ans;}
ll power(ll a,ll b){if(a==1) return 1;ll ans=1;while(b>0){if(b&1)ans=(ans*a);a=(a*a);b=b>>1;}return ans;}
const int INF=1000000000000000000;

//always try to hack ur soln before submitting (penalty-50 wrong submission 50 min sochle isse aacha)
// Abe n*m ke grid main y ke coordinates m se akm hone chahiye na ke n se 


int32_t main()
{
	IOS;
	int t;
	t=1;
	while(t--)
	{
		int x,y;
		cin>>x>>y;
		cout<<(x+y)/2<<" "<<(x-y)/2<<"\n";
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
using graph = vector<VI>;
template<class T = ll> using w_graph = vector<vector<pair<int, T>>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define SORT(a) sort(a.begin(),a.end())
#define rSORT(a) sort(a.rbegin(),a.rend())
#define fSORT(a,f) sort(a.begin(),a.end(),f)
#define all(a) a.begin(),a.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define tp(a,i) get<i>(a)
#ifdef _DEBUG
#define line cout << "-----------------------------\n"
#define stop system("pause")
#endif
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
template<class T>inline T sum(const vector<T>& a, int l, int r) { return a[r] - (l == 0 ? 0 : a[l - 1]); }
template<class T>inline void END(T s) { print(s); exit(0); }
void END() { exit(0); }

VS s(3);
string t;
vector<bool> used(10);
VI num;
int m;
void dfs(int i) {
    if (i == m) {
        VS n = s;
        bool ng = false;
        FOR(j, 0, 3) {
            int f = lower_bound(all(t), s[j][0]) - t.begin();
            if (num[f] == 0)ng = true;
            FOR(k, 0, s[j].size()) {
                int idx = lower_bound(all(t), s[j][k]) - t.begin();
                n[j][k] = char('0' + num[idx]);
            }
        }
        if (ng)return;

        if (stoll(n[0]) + stoll(n[1]) == stoll(n[2])) {
            FOR(j, 0, 3)print(n[j]);
            END();
        }
    }
    else {
        FOR(j, 0, 10) {
            if (used[j])continue;
            used[j] = true;
            num[i] = j;
            dfs(i + 1);
            used[j] = false;
        }
    }
}
int main() {
    init();

    cin >> s;
    set<char> se;
    FOR(i, 0, 3)for (char c : s[i])se.insert(c);
    for (char c : se)t += c;
    SORT(t);
    m = t.size();
    num.resize(m);
    dfs(0);
    print("UNSOLVABLE");

    return 0;
}