#include #include using namespace std; int main() { int V, D; cin >> V >> D; bitset<1000> G[1000]; string E; for (int i = 0;i < V;++ i) { cin >> E; G[i] = bitset<1000>(E); } bool ans = G[0].any(); for (int i = 0;i < V;++ i) { bitset<1000> now, one, two, three, tmp; now = G[i]; one[i] = true; for (int j = 1;j < D;++ j) { tmp = now ^ two; if (tmp.none()) break; three |= one; for (int k = 0;k < V;++ k) if (tmp[k]) three |= G[k]; tmp = three; three = two; two = one; one = now; now = tmp; } ans &= now.count() == V; } cout << (ans ? "Yes" : ":(") << endl; return 0; }