#include using namespace std; using pi = pair; using bs = bitset<1000>; signed main() { int v, d; cin >> v >> d; vector G(v); for (int i = 0; i < v; ++i) { string s; cin >> s; for (int j = 0; j < v; ++j) if (s[j] == '1') G[i].set(j); } bool valid = true; for (int src = 0; valid && src < v; ++src) { if (!G[src].any()) { valid = false; break; } bs eprev, oprev, pos, onext, enext; pos.set(src); eprev.set(src); enext.set(src); int mv = 0; while (mv < d && pos.count() > 0) { for (int i = 0; i < v;++i) if (pos[i]) onext |= G[i]; pos = onext ^ oprev; oprev = onext; ++mv; if (mv >= d) break; for (int i = 0; i < v; ++i) if (pos[i]) enext |= G[i]; pos = enext ^ eprev; eprev = enext; ++mv; if (mv >= d) break; } if(d%2){ for (int i = src; valid && i < v; ++i) if (!oprev[i]) valid = false; } else { for (int i = src; valid && i < v; ++i) if (!eprev[i]) valid = false; } } cout << (valid ? "Yes" : ":(") << endl; }