#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define MAXN 100
#define MAXM 1001
vector<int> arr[MAXN];
int pi[MAXM][MAXM];
int N,K;
int min_len = 1000;
void getpi(int start){
int j = start;
for (int i = start+1; i <= start+K; i++){
while (j>start && arr[0][i] != arr[0][j]) j = pi[start][j-1];
if (arr[0][i] == arr[0][j]){
pi[start][i] = ++j;
}
}
}
bool kmp(int start){
int cnt = 0;
for (int k = 1 ; k< N; k++){
bool flag = false;
for (int kk = 0 ; kk<2&&!flag; kk++){
int j = start;
if(kk) reverse(arr[k].begin(),arr[k].end());
for (int i = 0; i < arr[k].size();i++){
while (j>start && arr[k][i]!=arr[0][j]) j =pi[start][j-1];
if (arr[k][i] == arr[0][j]){
if (j == start+ K-1){
cnt++;
flag = true;
break;
}
else j++;
}
}
if(kk) reverse(arr[k].begin(),arr[k].end());
}
}
return cnt==N-1;
}
bool is_possible(){
// 바이러스 코드가 k개인 경우 모두 조사
for (int i= 0; i <=arr[0].size()-K; i++){
getpi(i);
if (kmp(i)) return true;
}
return false;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin >> N >> K;
for (int i = 0 ;i < N; i++){
int m;
cin >> m;
min_len = min(min_len,m);
arr[i] = vector<int>(m,0);
for (int j = 0;j<m; j++){
cin >> arr[i][j];
}
}
bool ans = is_possible();
if (ans) cout <<"YES\n";
else cout <<"NO\n";
return 0;
}