#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> s;
  int p = 0;
  int ans = 0;
  for (int(i) = 0; (i) < (M); (i)++) {
    int k;
    int sw = 0;
    cin >> k;
    for (int(j) = 0; (j) < (k); (j)++) {
      int t;
      cin >> t;
      sw |= (1 << (t - 1));
    }
    s.push_back(sw);
  }
  for (int(i) = 0; (i) < (M); (i)++) {
    int t;
    cin >> t;
    p |= (t << i);
  }
  for (int bit = 0; bit < (1 << N); bit++) {
    bool f = true;
    for (int(i) = 0; (i) < (M); (i)++) {
      if (__builtin_popcount((bit & s[i])) == 0) {
        f = false;
        break;
      }
      if (__builtin_popcount((bit & s[i])) % 2 == (p & (1 < i))) {
        f = false;
        break;
      }
    }
    if (f) ans++;
  }
  cout << ans << endl;
}
