#include<iostream> #define maxn 10007 using namespace std; int a[maxn], dis[107][107], n, m; int main(void) { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) cin >> dis[i][j]; for (int k = 1; k <= n; k++) for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) dis[i][j] = dis[i][j] | (dis[i][k] & dis[k][j]); for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) cout << dis[i][j] << ' '; cout << endl; } return 0; }