#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

void mod( ll &n, ll m=MOD ){ n%=m,n+=m,n%=m; }

const int MAXN = 1e5+5;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main() 
{
    fastio();

    int n,m;
    cin>>n>>m;

    int k[m+3],p[m+3];
    int s[m+3][n+3];

    loop(i,0,m)
    {
        cin>>k[i];
        loop(j,0,k[i])
        {
            cin>>s[i][j];
            s[i][j]--;
        }
    }
    loop(i,0,m) cin>>p[i];

    int ans = 0;
    int total = (1<<n);
    for(int i=0;i<total;i++)
    {
        int aa = 0;
        for(int bulb=0;bulb<m;bulb++)
        {
            int cc = 0;
            for(int kk=0;kk<k[bulb];kk++)
            {
                if( s[bulb][kk]&i )
                {
                    cc++;
                }
            }
            if( (cc-p[bulb])%2 == 0 )
            {
                aa++;
            }
        }
        if( aa == m )
        {
            ans++;
        }
    }

    cout<<ans,nl;

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}