/** * @FileName a.cpp * @Author kanpurin * @Created 2021.02.21 19:45:28 **/ #include "bits/stdc++.h" using namespace std; typedef long long ll; const int MAX_LEN = 20; struct bitmatrix{ vector> bs1; vector> bs2; bitmatrix(){ bs1.resize(MAX_LEN); bs2.resize(MAX_LEN); } void build() { for (int i = 0; i < MAX_LEN; i++) { for (int j = 0; j < MAX_LEN; j++) { if (bs1[i][j]) { bs2[j].set(i); } } } } bitmatrix operator*=(bitmatrix &bm) { bitmatrix ret; for (int i = 0; i < MAX_LEN; i++) { for (int j = 0; j < MAX_LEN; j++) { if ((this->bs1[i] & bm.bs2[j]).any()) { ret.bs1[i].set(j); } } } ret.build(); this->bs1 = ret.bs1; this->bs2 = ret.bs2; return ret; } }; template T _pow(T k, U n, T unity = 1) { while (n > 0) { if (n & 1) { unity *= k; } k *= k; n >>= 1; } return unity; } int main() { int v;ll d;cin >> v >> d; bitmatrix bm; for (int i = 0; i < v; i++) { string s;cin >> s; bm.bs1[i] = bitset(s); } bm.build(); bitmatrix I; for (int i = 0; i < MAX_LEN; i++) { I.bs1[i].set(i); I.bs2[i].set(i); } bm = _pow(bm,d,I); for (int i = 0; i < v; i++) { if (bm.bs1[i].count() != v) { puts("No"); return 0; } } puts("Yes"); return 0; }