#include<iostream>
#include<vector>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> op(N);
  int i;
  char s[4];
  for(i=0;i<N;i++) {
    cin >> s;
    if(s[0] == 'A')op[i] = 0;
    else op[i] = 1;
  }
  vector<long long> dp0(N+1,0),dp1(N+1,0);
  dp0[0] = dp1[0] = 1;
  for(i=0;i<N;i++) {
    if(op[i]==0) {
      dp0[i+1] = dp0[i]*2 + dp1[i];
      dp1[i+1] = dp1[i];
    }
    else {
      dp0[i+1] = dp0[i];
      dp1[i+1] = dp0[i] + dp1[i]*2;
    }
  }
  cout << dp1[N] << endl;
}
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
inline ll mask(const ll &k) { return (1LL << k) - 1LL; }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
template <class T>
int lwb(V<T> &v, const T &x) { return lower_bound(all(v), x) - v.begin(); }
template <class T>
int upb(V<T> &v, const T &x) { return upper_bound(all(v), x) - v.begin(); }
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&...tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
//////////////////////////////////////////////INSERT ABOVE HERE
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    V<V<int>> c(n, V<int>(n));
    for (int i = 0; i < n; i++) {
        read(c[i]);
    }
    V<int> aa(n), bb(n);
    for (int i = 0; i + 1 < n; i++) {
        bb[i] = c[0][i + 1] - c[0][i];
        aa[i] = c[i + 1][0] - c[i][0];
    }
    for (int i = 1; i < n; i++) {
        for (int j = 0; j + 1 < n; j++) {
            if (c[j + 1][i] - c[j][i] != aa[j]) {
                cout << "No" << newl;
                return 0;
            }
            if (c[i][j + 1] - c[i][j] != bb[j]) {
                cout << "No" << newl;
                return 0;
            }
        }
    }
    V<int> a(n);
    V<int> b(n);
    bool f = true;
    a[0] = 0;
    b[0] = 0;
    int ma = 0, mb = 0;
    for (int i = 0; i + 1 < n; i++) {
        a[i + 1] = a[i] + aa[i];
        chmin(ma, a[i + 1]);
    }
    for (int i = 0; i + 1 < n; i++) {
        b[i + 1] = b[i] + bb[i];
        chmin(mb, b[i + 1]);
    }
    ma *= -1;
    mb *= -1;
    if (ma + mb > c[0][0]) {
        cout << "No" << newl;
    } else {
        a[0] = ma;
        b[0] = c[0][0] - ma;
        for (int i = 0; i + 1 < n; i++) {
            a[i + 1] = a[i] + aa[i];
        }
        for (int i = 0; i + 1 < n; i++) {
            b[i + 1] = b[i] + bb[i];
        }
        cout << "Yes" << newl;
        print(a);
        print(b);
    }
}
