#include <bits/stdc++.h>
using namespace std;
int on_bit(int N, int pos) { return N = N | (1 << pos); }
int off_bit(int N, int pos) { return N = N & ~(1 << pos); }
bool check_bit(long long int N, int pos) { return (bool)(N & (1 << pos)); }
template <class T>
inline bool read(T &x) {
  int c = getchar();
  int sgn = 1;
  while (~c && c < '0' || c > '9') {
    if (c == '-') sgn = -1;
    c = getchar();
  }
  for (x = 0; ~c && '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  x *= sgn;
  return ~c;
}
inline long long int exp(long long int a, long long int p) {
  if (p == 0) return 1;
  long long int x = exp(a, p / 2) % 1000000007;
  x = (x * x) % 1000000007;
  if (p & 1) x = (x * (a % 1000000007)) % 1000000007;
  return x;
}
inline int add(int a, int b) {
  a += b;
  if (a >= 1000000007) a -= 1000000007;
  return a;
}
inline int sub(int a, int b) {
  a -= b;
  if (a < 1000000007) a += 1000000007;
  return a;
}
inline int multi(long long int a, long long int b) {
  a *= b;
  if (a >= 1000000007) a %= 1000000007;
  return a;
}
int state[20];
int sw[20];
vector<int> adj[20];
int cnt = 0;
int n, m;
void solve(int pos) {
  if (pos > n) {
    bool flg = 0;
    for (int i = 1; i <= m; i++) {
      if (sw[i] % 2 != state[i]) flg = 1;
    }
    if (!flg) cnt++;
    return;
  }
  for (auto i : adj[pos]) {
    sw[i]++;
  }
  solve(pos + 1);
  for (auto i : adj[pos]) {
    sw[i]--;
  }
  solve(pos + 1);
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int x;
    cin >> x;
    for (int j = 0; j < x; j++) {
      int y;
      cin >> y;
      adj[x].push_back(y);
    }
  }
  for (int i = 1; i <= m; i++) cin >> state[i];
  memset((sw), 0, sizeof((sw)));
  solve(1);
  cout << cnt << "\n";
  return 0;
}
