#include<bits/stdc++.h>
using namespace std;
int a[15];
int da;
int n;
void dfs(int pos,int now,int target)
{
  if(pos == n){if(now == target)da++;return;}
  dfs(pos+1,now^a[pos],target);
  dfs(pos+1,now,target);
}
int main()
{
   int k;
  while(cin>>n>>k)
  {
    memset(a,0,sizeof(a));
    for(int i = 0; i < k; ++i)
    {
      int num;cin>>num;
      for(int j = 0; j < num ; ++j)
      {
         int x;cin>>x;a[x] |= (1<<i);
      }
    }
    int ans = 0;
    for(int i = 0; i < m; ++i)
    {
      int x;cin>>x;
      if(x)ans |= (1<<i);
    }
    da = 0;
    dfs(0,0,ans);
    cout<<da<<endl;
  }
}