#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> k(M);
    vector<vector<int>> S(M);
    REP(i, M) {
        cin >> k[i];
        REP(j, k[i]) {
            int tmp;
            cin >> tmp;
            S[i].push_back(tmp);
        }
    }
    vector<int> p(M);
    REP(i, M) { cin >> p[i]; }
    int res = 0;
    for(int bit = 0; bit < pow(2, N); bit++) {
        REP(i, M) {
            int cnt = 0;
            REP(j, k[i]) {
                if (bit & (1<<(S[i][j]-1)){
                    cnt++;
                }
                if(cnt%2 != p[i]){
                    break;
                }
            }
            if(i == M - 1) {
                res += 1;
            }
        }
    }
    cout << res << endl;
}
