#include #define ll long long #define INF 1000000005 #define MOD 1000000007 #define EPS 1e-10 #define rep(i,n) for(int i=0;i<(int)(n);++i) #define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i) #define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i) #define each(a,b) for(auto& (a): (b)) #define len(v) (int)(v).size() #define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end()) #define cmx(x,y) x=max(x,y) #define cmn(x,y) x=min(x,y) #define fi first #define se second #define pb push_back #define show(x) cout<<#x<<" = "<<(x)< P; typedef pair pll; typedef vector vi; typedef vector vvi; typedef vector vl; typedef vector vvl; typedef vector vd; typedef vector

vp; typedef vector vs; const int MAX_N = 2000; int n,m; template class mat { private: // (or, and) の意味での積(正方かつ対称行列に限る(重みなし無向グラフの隣接行列とか)) mat operator*(const mat& m) const { mat ans; for(int i = 0; i < COL_SIZE; i++){ for(int j = 0; j < COL_SIZE; j++){ if(this->a[i][j] == 0) continue; ans.a[i] |= m.a[j]; } } return ans; } public: bitset* a; int r; // 正方行列の場合 mat() : mat(COL_SIZE){} // 一般の行列の場合 mat(int row_size) : r(row_size){ a = new bitset[r]; } int rank() const { int res = 0; mat b(r); for(int i = 0; i < r; i++) b[i] = a[i]; for(int i = 0; i < COL_SIZE; i++){ if(res == r) return res; int pivot = res; if(!b[pivot][i]){ for(int j = res + 1; j < r; j++){ if(b[j][i]){ pivot = j; break; } } if(!b[pivot][i]) continue; swap(b[pivot], b[res]); } for(int j = res + 1; j < r; j++){ if(b[j][i]) b[j] ^= b[res]; } res++; } return res; } inline const bitset& operator[](size_t index) const { return a[index]; } inline bitset& operator[](size_t index){ return a[index]; } friend mat pow(mat m, long long cnt){ mat res; for(int i = 0; i < COL_SIZE; i++) res[i][i] = 1; while(cnt){ if(cnt & 1){ res = res * m; } m = m * m; cnt >>= 1; } return res; } }; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> n >> m; mat A; rep(i,n){ rep(j,n){ char c;cin >> c; A[i][j]=c-'0'; } } A=pow(A,min(m,5000)); bool ok=true; rep(i,n)rep(j,n)if(A[i][j]==0)ok=false; cout << (ok? "Yes":"No") <