#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, j, m, tempi, temp, ans = 0;
  cin >> n >> m;
  vector<long long> k(m);
  vector<vector<long long>> s(m, vector<long long>());
  vector<long long> p(m);
  for (i = 0; i < m; i++) {
    cin >> k[i];
    s[i] = vector<long long>(k[i]);
    for (j = 0; j < k[i]; j++) {
      cin >> s[i][j];
    }
  }
  for (i = 0; i < m; i++) {
    cin >> p[i];
  }
  for (i = 0; i < pow(2, n); i++) {
    ans++;
    vector<bool> state(n);
    tempi = i;
    for (j = 0; j < n; j++) {
      if (tempi % 2 == 0) {
        state[j] = true;
      } else {
        state[i] = false;
      }
      tempi = tempi / 2;
    }
    for (j = 0; j < m; j++) {
      temp = 0;
      for (long long bl : s[j]) {
        if (state[bl - 1]) temp++;
      }
      if (temp % 2 != p[j]) {
        ans--;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
