#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <stack>
using namespace std;
#define ll long long
#define ull unsigned long long
#define up(i, a, b) for (int i = (a); i <= (b); i++)
#define down(i, a, b) for (int i = (a); i >= (b); i--)
#define mem(x, y) memset(x, (y), sizeof x)
#define ff first
#define ss second
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define sc(a) scanf("%d", &a)
#define scl(a) scanf("%lld", &a)
#define scs(a) scanf("%s", a)
#define pr(a, b) printf("%d%c", a, b)
#define prl(a, b) printf("%lld%c", a, b)
#define PQ priority_queue
#define ld long double
#define all(v) v.begin(), v.end()
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> V;

int a[20][20],p[20];
int main(){
	//IOS;
	int n,m,ans=0;cin>>n>>m;
	up(i,1,m){
		cin>>a[i][0];
		up(o,1,a[i][0])cin>>a[i][o];
	}
	up(i,1,m)cin>>p[i];
	up(i,1,(1<<n)-1){
		int cmp=i,cur[20],cnt=0;
		up(o,1,10)cur[o]=0;
		while(cmp)cur[++cnt]=cmp&1,cmp>>=1;
		
		int light[20];
		up(o,1,10)light[o]=0;
		up(o,1,m)up(p,1,a[o][0])light[o]+=cur[a[o][p]];
		
		int gg=0;
		up(o,1,m)if((light[o]&1)!=p[o]){
			gg++;break;
		}
		if(!gg)ans++;
	}
	cout<<ans<<"\n";
}