#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 1e17;
const int INF = 1e9;
const double PI = acos(-1);
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) {
  long long g = gcd(a, b);
  return a / g * b;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> k(m);
  vector<vector<int> > s(m, vector<int>(n));
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> s[i][j];
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; i++) cin >> p[i];
  int cnt = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    vector<int> w(n);
    for (int i = 0; i < n; i++) {
      if (bit >> i & 1) {
        w[i] = 1;
      } else {
        w[i] = 0;
      }
    }
    int sum = 0;
    bool turn = true;
    for (int i = 0; i < m; i++) {
      for (int j = 0; j < k[i]; j++) {
        sum += w[s[i][j] - 1];
      }
      if (sum % 2 != p[i]) {
        turn = false;
        break;
      }
    }
    if (turn) cnt++;
  }
  cout << cnt << endl;
  return 0;
}
