package yukicoder_3785; import java.util.BitSet; import java.util.Scanner; public class Main2 { public static void main(String[] args) { new Main2(); } public Main2() { try (Scanner sc = new Scanner(System.in)) { int V, D; V = sc.nextInt(); D = sc.nextInt(); BitSet[] graph = new BitSet[V]; for (int i = 0;i < V;++ i) { graph[i] = new BitSet(V); String E = sc.next(); for (int j = 0;j < V;++ j) graph[i].set(j, E.charAt(j) == '1'); } boolean ans = graph[0].cardinality() > 0; for (int i = 0;i < V;++ i) { BitSet now = (BitSet)graph[i].clone(), one = new BitSet(V), two = new BitSet(V), three = new BitSet(V); one.set(i); for (int j = 1;j < D;++ j) { BitSet check = (BitSet)now.clone(); check.xor(two); if (check.isEmpty()) break; two = (BitSet)one.clone(); for (int k = check.nextSetBit(0);k >= 0;k = check.nextSetBit(k + 1)) one.or(graph[k]); three = now; now = one; one = three; } ans &= now.cardinality() == V; } System.out.println(ans ? "Yes" : ":("); } } }