#include <bits/stdc++.h>
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF = (long long)1E17;
long mod(long a) {
  long long c = a % (long long)(1E9 + 7);
  if (c >= 0) return c;
  return c + (long long)(1E9 + 7);
}
using namespace std;
bool prime(int n) {
  if (n == 1) {
    return false;
  } else if (n == 2) {
    return true;
  } else {
    for (int i = 2; i <= sqrt(n); i++) {
      if (n % i == 0) {
        return false;
      }
    }
    return true;
  }
}
long long gcd(long long a, long long b) {
  if (a < b) {
    swap(a, b);
  }
  if (a % b == 0) {
    return b;
  } else {
    return gcd(b, a % b);
  }
}
long long lcm(long long x, long long y) { return (x / gcd(x, y)) * y; }
class UnionFind {
 public:
  vector<int> Parent;
  UnionFind(int N) { Parent = vector<int>(N, -1); }
  int root(int A) {
    if (Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
  int size(int A) { return -Parent[root(A)]; }
  bool connect(int A, int B) {
    A = root(A);
    B = root(B);
    if (A == B) {
      return false;
    }
    if (size(A) < size(B)) swap(A, B);
    Parent[A] += Parent[B];
    Parent[B] = A;
    return true;
  }
};
int main() {
  int n, m;
  cin >> n >> m;
  int k[m];
  vector<vector<int>> s;
  int ts;
  int p[m];
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> ts;
      ts--;
      s[i].push_back(ts);
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int ans = 0;
  int cnt = 0;
  bool flag = true;
  for (int i = 0; i < (1 << 10); i++) {
    for (int j = 0; j < m; j++) {
      for (int r = 0; r < k[j]; r++) {
        if (i >> s[j][r] & 1) {
          cnt++;
        }
      }
      if (cnt % 2 == p[j]) {
        cnt = 0;
        continue;
      } else {
        cnt = 0;
        flag = false;
        break;
      }
    }
    if (flag) {
      ans++;
    } else {
      flag = true;
    }
  }
  cout << ans << endl;
  return 0;
}
