#include <bits/stdc++.h>
long long gcd(long long x, long long y) {
  if (y == 0)
    return x;
  else
    return gcd(y, x % y);
}
long long lcm(long long x, long long y) { return x / gcd(x, y) * y; }
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m);
  vector<int> k(m);
  for (int i = 0; i < (m); i++) {
    cin >> k[i];
    for (int j = 0; j < (k[i]); j++) {
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  vector<int> p(m);
  for (int i = 0; i < (m); i++) {
    cin >> p[i];
  }
  long long ans = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    bool f = true;
    for (int i = 0; i < m; i++) {
      int count = 0;
      for (int j = 0; j < k[i]; j++) {
        if (bit & (1 << s[i][j])) count++;
      }
      if (count % 2 != p[i]) f = false;
    }
    if (f == true) ans++;
  }
  cout << ans << endl;
  return 0;
}
