#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
int a[1001][1001];
int ans[1001];
const int LG = 31;
int n;
void processbit(int z)
{
for(int i = 0; i < n; i++)
{
for(int j = 0; j < n; j++)
{
if(a[i][j]==-1) continue;
if(a[i][j]&(1<<z))
{
}
else
{
if(ans[i]&(1<<z)) ans[i]^=(1<<z);
if(ans[j]&(1<<z)) ans[j]^=(1<<z);
}
}
}
}
bool checkans()
{
for(int i = 0; i < n; i++)
{
for(int j = 0; j < n; j++)
{
if(a[i][j]==-1) continue;
if((ans[i]|ans[j])==a[i][j])
{
}
else
{
return false;
}
}
}
return true;
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n;
for(int i = 0; i < n; i++)
{
for(int j = 0; j < n; j++)
{
cin>>a[i][j];
}
ans[i] = INT_MAX;
}
for(int i = 0; i < LG; i++) processbit(i);
if(!checkans())
{
cout<<"NO\n";
}
else
{
for(int i = 0; i < n; i++) cout<<ans[i]<<' ';
}
}