import java.util.Scanner;
import java.util.ArrayList;
class Main
{
private static void dfs(int v, int p, ArrayList<ArrayList<Integer>> g , int[] A) {
A[v]++;
if (A[v]>1)
return;
for (int i=0; i<g.get(v).size(); i++)
{
if (g.get(v).get(i)!=p)
dfs(g.get(v).get(i), v, g, A);
}
}
public static void main
(String[] args
) {
Scanner scanner
= new Scanner
(System.
in); int n = scanner.nextInt();
int[] A = new int[n];
ArrayList<ArrayList<Integer>> g = new ArrayList<ArrayList<Integer>>();
for (int i=0; i<n; i++) {
ArrayList<Integer> r = new ArrayList<Integer>();
for (int j=0; j<n; j++) {
int a = scanner.nextInt();
if (a==1) {
r.add(j);
}
}
g.add(r);
}
int t=0;
dfs(0, -1, g, A);
for (int i=0; i<n; i++)
{
if (A[i]!=1)
{
t++;
break;
}
}
if (t!=0)
else
}
}
aW1wb3J0IGphdmEudXRpbC5TY2FubmVyOwppbXBvcnQgamF2YS51dGlsLkFycmF5TGlzdDsKCmNsYXNzIE1haW4KewoJcHJpdmF0ZSBzdGF0aWMgdm9pZCBkZnMoaW50IHYsIGludCBwLCBBcnJheUxpc3Q8QXJyYXlMaXN0PEludGVnZXI+PiBnICwgaW50W10gQSkgewoJCUFbdl0rKzsKCQlpZiAoQVt2XT4xKQoJCQlyZXR1cm47CgkJZm9yIChpbnQgaT0wOyBpPGcuZ2V0KHYpLnNpemUoKTsgaSsrKQoJCXsKCQkJaWYgKGcuZ2V0KHYpLmdldChpKSE9cCkKCQkJCWRmcyhnLmdldCh2KS5nZXQoaSksIHYsIGcsIEEpOwoJCX0KCX0KCQoJcHVibGljIHN0YXRpYyB2b2lkIG1haW4gKFN0cmluZ1tdIGFyZ3MpCgl7CgkJU2Nhbm5lciBzY2FubmVyID0gbmV3IFNjYW5uZXIoU3lzdGVtLmluKTsKCQlpbnQgbiA9IHNjYW5uZXIubmV4dEludCgpOwoJCWludFtdIEEgPSBuZXcgaW50W25dOwoJCUFycmF5TGlzdDxBcnJheUxpc3Q8SW50ZWdlcj4+IG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