#include <bits/stdc++.h>
using namespace std;
int p[10];
int combination(int n, int m, vector<int>* v, string ans = "") {
  if (n == 0) {
    int temp = 0;
    for (int i = 0; i < m; i++) {
      for (auto j : v[i]) temp += (ans[j] - '0');
      if (temp % 2 != p[i]) return 0;
    }
    return 1;
  }
  return combination(n - 1, m, v, ans + "0") +
         combination(n - 1, m, v, ans + "1");
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v[m];
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int x;
      cin >> x;
      x--;
      v[i].push_back(x);
    }
  }
  for (int i = 0; i < m; i++) cin >> p[i];
  cout << combination(n, m, v);
  return 0;
}
