#include #include #include using namespace std; int n,l,ans,size[100],num[100][20],in[305]; void dfs(int x,int zt,int lj){if (ans) return; if (zt==(1<n) return; if ((zt>>(x-1))&1) dfs(x+1,zt,lj); for (int i=1;i<=size[x];i++) dfs(x+1,zt|in[num[x][i]],lj+1); } int main(){ int tt;scanf("%d",&tt); for (;tt--;){ ans=0;memset(in,0,sizeof(in)); scanf("%d%d",&n,&l); for (int i=1;i<=n;i++){ scanf("%d",&size[i]); for (int j=1;j<=size[i];j++){ scanf("%d",&num[i][j]); in[num[i][j]]|=(1<<(i-1)); } } dfs(1,0,0); if (ans) puts("YES"); else puts("NO"); } }