#include <bits/stdc++.h>
using namespace std;
const int N = 1000000;
const long long mod = 1000000007;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m);
  for (long long int i = 0; i < m; i++) {
    int k;
    cin >> k;
    s[i].resize(k);
    for (long long int j = 0; j < k; j++) {
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  vector<int> p(m);
  for (long long int i = 0; i < m; i++) cin >> p[i];
  int ans = 0;
  for (int bit = 0; bit < (1 << n); ++bit) {
    bool flag = true;
    for (int j = 0; j < m; j++) {
      int count = 0;
      int o = s[j].size();
      for (int k = 0; k < o; k++) {
        if (bit & (1 << k)) {
          count++;
        }
      }
      if (count % 2 != p[j]) {
        flag = false;
        break;
      }
    }
    if (flag) ans++;
  }
  std::cout << ans << std::endl;
}
