import java.io.*;

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

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

public class Corrige8 {

    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 produit (Graphe a, Graphe b) {
        Graphe c = new Graphe(a.nb_som);
        for (int i=0; i<a.nb_som; i++) 
            for (int j=0; j<a.nb_som; j++) {
                c.mat[i][j] = 0;
                for (int k=0; k<a.nb_som; k++) 
                    c.mat[i][j] += a.mat[i][k] * b.mat[k][j];
            }
        return(c);
    }

    public static boolean connecteDeux (Graphe a, int i, int j) {
        return(produit(a,a).mat[i][j] >= 1);
    }
    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 main (String[] args) {
        Graphe g = saisit();
        affiche(g); 
        System.out.println(
            connecteDeux(
                g, Integer.parseInt(Lire()), Integer.parseInt(Lire())));
    }
}
