#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

// order statistics tree
typedef tree<pii, null_type, less<pii>, rb_tree_tag,
             tree_order_statistics_node_update> indexed_set;

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()


const int N = 11;
int n, m;
vector<int> bulb[N];
int p[N];
bool on[N];
int ans;
void bt(int i){
  if(i > n){
    // got a possible combination of switches

    // count number of switches on for each bulb
    // if one bulb is off then end the loop
    bool all_on = true;
    rep(j, 0, m){
      int s_on = 0;
      trav(s, bulb[j]){
        if(on[s]) s_on++;
      }
      if(s_on % 2 != p[j]){
        all_on = false;
        break;
      }
    }

    ans += all_on ? 1 : 0;
  } else {
    on[i] = true;
    bt(i+1);
    on[i] = false;
    bt(i+1);
  }
}

int main() {
  cin.tie(0); cin.exceptions(cin.failbit);
  scanf("%d%d", &n, &m);
  rep(i, 0, m){
    int n_switches;
    scanf("%d", &n_switches);
    rep(i, 0, n_switches){
      int sw;
      scanf("%d", &sw);
      bulb[i].PB(sw);
    }
  }

  rep(i, 0, m) scanf("%d", p+i);

  bt(1);
  printf("%d\n", ans);
}
