#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
long long mod = 1000000007;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
long long dp[100100][13];
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m);
  vector<int> p(m);
  for (int i = 0; i < m; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int x;
      cin >> x;
      x--;
      s[i].push_back(x);
    }
  }
  for (int i = 0; i < m; ++i) {
    cin >> p[i];
  }
  long long ans = 0;
  for (int bit = 0; bit < (1 << n); ++bit) {
    bool ok = true;
    for (int i = 0; i < m; ++i) {
      int tmp = 0;
      for (int v = 0; v < s[i].size(); v++) {
        if (bit & (1 << v)) tmp++;
      }
      if (tmp % 2 != p[i]) ok = false;
    }
    if (ok) ans++;
  }
  cout << ans << endl;
  return 0;
}
