#include <bits/stdc++.h>
#define MOD (long long)(1E9+7)
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
	int n,m;
	cin >> n;
	vector<vector<int>> x(n);
	rep(i, n){
      	rep(j, n) {
			cin >> m;
          	x[i].push_back(m);
        }
	}
  	if(n==1) {
    	cout << "Yes" << endl; 
      	cout << x[0][0] << endl << 0 << endl;
      	return 0;
    }
  	vector<int> hor(n-1);
  	vector<int> ver(n-1);
  	long long a=0, b=0, minA=0, minB=0;
  	rep(i, n-1) {
    	hor[i] = x[0][i+1] - x[0][i];
      	ver[i] = x[i+1][0] - x[i][0];
      	a += hor[i];
      	b += ver[i];
      	if(a<minA) minA=a;
      	if(b<minB) minB=b;
    }
  	rep(i, n-1) {
    	rep(j, n-1) {
        	if(x[i+1][j+1] - x[i+1][j] != hor[j]) {
            	cout << "No" << endl;
            	return 0;
            }
        	if(x[i+1][j+1] - x[i][j+1] != ver[i]) {
            	cout << "No" << endl;
            	return 0;
            }
        }
    }
	cout << "Yes" << endl;
    int A, B;
  	if(minB<0 && minB < minA) {
      A = -minB;
  	  B = x[0][0] - A;	
    } else if(minA<0) {
      B = -minA;
      A = x[0][0] - B;
    } else {
    	A = x[0][0]/2;
      B = x[0][0] - A;
    }
  	
  cout << A;
	rep(i, n-1) {
      	A += ver[i];
      	cout << " " << A;
    }
  	cout << endl << B;
  	rep(i, n-1) {
      	B += hor[i];
      	cout << " " << B;
    }
  	cout << endl;
}
/**
 * author: said_v15
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
 
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
 
typedef long long  ll;

#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define pb push_back 
#define sc second 
#define f first 
#define kek cout<<"\n";
#define fla cout<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(v) ((v).begin()), ((v).end()) 
// #define int ll


const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const int MAXN = 200100;
const int INF = 1e8;
const ll LL_INF=1e18;
const double pi=3.1415926535;

int divide(int a, int b)
{
          return (a+b-1)/b;
}

int32_t main()
{
    #if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
    #endif
 fast;
 // cout << fixed << setprecision(12) << ans;
 // string al = "abcdefghijklmnopqrstuvwxyz";
 
 int questions=1;
 // cin>>questions;
 while(questions--)
 {
          string s;
          cin>>s;
          int ans=INF;
          int n=s.size();
          for(int i=0;i<(1<<n);i++) 
          {
                    int sum=0;
                    int cnt=0;
                    bool ok=false;
                    for(int j=0;j<n;j++) 
                    {
                              if(i&(1<<j)) 
                              {
                                  sum+=(s[j]-'0');
                                  cnt++;
                                  ok=true;
                              }
                    }
                    if(ok && sum%3==0) 
                    {
                              ans=min(ans, n-cnt);
                    }
          }
          if(ans==INF) cout<<-1;
          else cout<<ans;
           
         
 }
    
 
 // !!! LOOK AT NUMBER OF QUESTIONS IN A PROBLEM !!! (cin>>questions)
 

  // cout <<"Runtime is:"<<clock() * 1.0 / CLOCKS_PER_SEC <<endl;
   return 0;
   
}
