#include <bits/stdc++.h>   using namespace std;   int n, a[52][52], d[52], dd[52], c[52], b[52][52];   bool check(int pos) {     int t[n + 2];     for (int i = 1; i <= n; i++) t[i] = d[i];     for (int i = 1; i <= n; i++)       if (t[i] == n && i != pos) t[i] = n - 1;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) {         if (i == j)           b[i][j] = 0;         else {           b[i][j] = min(t[i], t[j]);         }       }     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++)         if (a[i][j] != b[i][j]) return 0;     return 1;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) cin >> a[i][j];     for (int i = 1; i <= n; i++) {       for (int j = 0; j < n + 1; j++) dd[j] = 0;       for (int j = 1; j <= n; j++) dd[a[i][j]] = 1;       if (dd[n - 1] == 1) {         c[n] = 1;         d[i] = n;       }       if (d[i]) continue;       for (int j = 0; j < n + 1; j++) {         if (dd[j] == 0 && c[j - 1] == 0) {           c[j - 1] = 1;           d[i] = j - 1;           break;         }       }     }     int pos = -1;     for (int i = 1; i <= n; i++) {       if (d[i] == n) {         if (check(i)) {           pos = i;           break;         }       }     }     for (int i = 1; i <= n; i++)       if (d[i] == n && i != pos) d[i] = n - 1;     for (int i = 1; i <= n; i++) cout << d[i] <<    ;   }   