#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b)for(int i=a;i<b;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
int power(int x,int n)
{
  if(n==0)return 1;
  int temp=power(x,n/2);
  if(n%2==0)return temp*temp;
  return x*temp*temp;
}
int32_t main()
{
   fastio
   int n,m;
   cin>>n>>m;
   vector<int>v[10];
   int num=power(2,n);
   int p[m];
   rep(i,m)
   {
     int k;
     cin>>k;
     rep(j,k)
       {
         int a;
         cin>>a;
         v[i].pb(a);
       }
   }
   rep(i,m)cin>>p[i];
   int ans=0;
   for(int i=0;i<=num;i++)
   {
     int flag=0;
     for(int j=0;j<m;j++)
     {
       int c=0;
       for(int p=0;p<v[j].size();p++)
       {
         int temp=v[j][p];
         temp--;
         if((1<<temp) & i)c++;
       }
       c=c%2;
       if(c==p[j])continue;
       else {flag=1;break;}
     }
     if(flag==0)ans++;
   }
   cout<<ans<<endl;
   return 0;
}
