#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  vector<int> count(m, 0);
  int ans = 0;
  rep(i,m) {
    int k;
    cin >> k;
    rep(j,k) {
      int s;
      cin >> s;
      s--;
      a[s] |= (1<<i);
    }
  }
  int p = 0;
  rep(i,m) {
    int x;
    cin >> x;
    p |= (x<<i);
  }
  rep(i,1<<n) {
    int t = 0;
    rep(j,n) if(i>>j&1) t ^= a[j];
    if(t==p) ans++;
  }
  cout << ans << endl;
  return 0;
}