#include <bits/stdc++.h>
using namespace std;
template <class X>
void pr(X test) {
  cout << test << endl;
}
template <class X>
void prr(X test) {
  for (auto it : test) {
    cout << it << endl;
  }
}
template <class X>
void prrr(X test) {
  int f = 0;
  for (auto it : test) {
    cout << (f++ != 0 ? " " : "") << it;
  }
  cout << endl;
}
class UF {
 public:
  int *id;
  int cnt;
  int *sz;
  UF(int N) {
    cnt = N;
    id = new int[N];
    sz = new int[N];
    for (int i = 0; i < N; i++) {
      id[i] = i;
      sz[i] = 1;
    }
  }
  ~UF() {
    delete[] id;
    delete[] sz;
  }
  int find(int p) {
    int root = p;
    while (root != id[root]) root = id[root];
    while (p != root) {
      int newp = id[p];
      id[p] = root;
      p = newp;
    }
    return root;
  }
  void merge(int x, int y) {
    int i = find(x);
    int j = find(y);
    if (i == j) return;
    if (sz[i] < sz[j]) {
      id[i] = j;
      sz[j] += sz[i];
    } else {
      id[j] = i;
      sz[i] += sz[j];
    }
    cnt--;
  }
  bool connected(int x, int y) { return find(x) == find(y); }
  int count() { return cnt; }
};
vector<long long> divv(long long n) {
  vector<long long> v;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      v.push_back(i);
      if (i * i != n) v.push_back(n / i);
    }
  }
  sort(v.begin(), v.end());
  return v;
}
int main() {
  long long n, m, l;
  cin >> n >> m;
  vector<long long> v[n + 2];
  for (long long i = 0; i < m; i++) {
    long long a;
    cin >> a;
    for (long long j = 0; j < a; j++) {
      long long s;
      cin >> s;
      v[i + 1].push_back(s);
    }
  }
  long long p[m + 2];
  for (long long i = 0; i < m; i++) {
    long long a;
    cin >> a;
    p[i + 1] = a;
  }
  long long u = pow(2, n);
  long long ans = 0;
  for (long long i = 0; i < u; i++) {
    long long tt = i;
    unordered_map<long long, long long> mm;
    for (long long j = 0; j < n; j++) {
      if (tt % 2 == 1) mm[j + 1] = 1;
      tt /= 2;
    }
    bool b = true;
    for (long long j = 0; j < m; j++) {
      long long sum = 0;
      for (auto it : v[j + 1]) {
        if (mm[it] == 1) sum++;
      }
      if (p[j + 1] == (sum % 2))
        continue;
      else {
        b = false;
        break;
      }
    }
    if (b) ans++;
  }
  pr(ans);
  return 0;
}
