#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};

int arr[] = {0,1,2,3,4,5,6,7,8,9};
map<char,int> mp;
LL getInt(string s){
    reverse(s.begin(), s.end());
    LL res = 0;
    LL base = 1;
    for(char c : s){
        res += base * arr[mp[c]];
        base *= 10;
    }

    return res;

}

bool check(string s){
    int idx = mp[s[0]];
    int x = arr[idx];
    if(x == 0) return false;
    else return true;
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    string A,B,C; cin >> A >> B >> C;
    set<char> se;
    for(char c : A) se.insert(c);
    for(char c : B) se.insert(c);
    for(char c : C) se.insert(c);
    int len = 0;
    for(char c : se) len++;
    if(len > 10){
        cout << "UNSOLVABLE" << endl;
        return 0;
    }
    int idx = 0;
    for(char c : se){
        mp[c] = idx;
        idx++;
    }

    do{
        if(!check(A) || !check(B) || !check(C)) continue;
        LL Ax = getInt(A);
        LL Bx = getInt(B);
        LL Cx = getInt(C);

        if(Ax + Bx == Cx){
            cout << Ax << endl;
            cout << Bx << endl;
            cout << Cx << endl;
            return 0;
        }
        
    }while(next_permutation(arr, arr+10));


    cout << "UNSOLVABLE" << endl;
}
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

// AtCoder
// #include <atcoder/all>
// using namespace atcoder;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...)
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b)-1, i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

constexpr ll INF = 1e18;
int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<vector<ll>> c(n, vector<ll>(n, 0));
    rep (i, n) rep (j, n) cin >> c[i][j];
    rep (i, n) rep (j, n) {
        if (c[i][j] - c[i][0] != c[0][j] - c[0][0]) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n"; // 忘れない！
    vector<ll> a(n, INF), b(n, INF);
    rep (i, n) rep (j, n) {
        chmin(a[i], c[i][j]);
        chmin(b[j], c[i][j]);
    }
    ll am = *min_element(all(a)), bm = *min_element(all(b));
    transform(all(a), a.begin(), [&](ll x){return x - am;});
    // transform(all(b), b.begin(), [&](ll x){return x - bm;});
    rep (i, n) cout << a[i] << " \n"[i + 1 == n];
    rep (i, n) cout << b[i] << " \n"[i + 1 == n];
    return 0;
}