#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long double EPS = 0.0000000001;
int n, m;
bool check(int x, vector<vector<int>> s, vector<int> p) {
  vector<int> state(n);
  for (int i = 0; i < n; i++) {
    if (x % 2 == 1) state[i] = 1;
    x /= 2;
  }
  for (int i = 0; i < m; i++) {
    int tmp = 0;
    for (int j = 0; j < s[i].size(); j++) {
      tmp += state[s[i][j]];
    }
    if (tmp % 2 != p[i]) return 0;
  }
  return 1;
}
int main() {
  cin >> n >> m;
  vector<vector<int>> s(m);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    vector<int> v(k);
    for (int j = 0; j < k; j++) {
      cin >> v[j];
      s[i] = v;
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; i++) cin >> p[i];
  int ans = 0;
  for (int i = 0; i < (1 << n); i++) {
    ans += check(i, s, p);
  }
  cout << ans << endl;
}
