import java.io.*;

class Graphe {
    int nb_som;
    int mat[][];

    Graphe (int n){
        nb_som = n;
        mat = new int[n][n];
    }
}

public class CodeTd9 {

    public static String Lire () {
        BufferedReader in = 
            new BufferedReader(new InputStreamReader(System.in));
        String s;
        try { s = in.readLine(); }
        catch (IOException e) { s = "echec"; }
        return(s);
    }

    public static Graphe saisit () {
        Graphe a = new Graphe(Integer.parseInt(Lire()));
        for (int i=0; i<a.nb_som; i++)
            for (int j=0; j<a.nb_som; j++)
                a.mat[i][j] = Integer.parseInt(Lire()); 
        return(a);
    }

    public static void affiche (Graphe a) {
        for (int i=0; i<a.nb_som; i++) {
            for (int j=0; j<a.nb_som; j++)
                System.out.print(a.mat[i][j] + " "); 
            System.out.println(); 
        }
    }

    public static void f (Graphe a) {
        for (int i=a.nb_som-1; i>0; i=i-1) {
            int j = 0;
            while (j<a.nb_som && a.mat[i][j]==0)
                j = j + 1;
            if (j==a.nb_som)
                System.out.println(-1); 
            else
                System.out.println(j); 
        }
    }

    public static void main (String[] args) {
        Graphe g = saisit();
        affiche(g); 
        f(g);
    }
}
