#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1e-10;
const long long INF = 1e18;
const int MOD = (int)1e9 + 7;
const long double PI = acos(-1.0L);
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> K(M, vector<int>(0));
  for (int i = 0; i < (M); i++) {
    int k;
    cin >> k;
    for (int j = 0; j < (k); j++) {
      int s;
      cin >> s;
      K[i].push_back(s);
    }
  }
  vector<int> pair<int, int>(M);
  for (int i = 0; i < (M); i++) cin >> pair<int, int>[i];
  int ans = 0;
  for (int n = 0; n < (1 << N); n++) {
    int l = 0;
    int on = 0;
    for (int m = 0; m < (M); m++) {
      int p = pair<int, int>[m];
      for (int k = 0; k < (K[m].size()); k++) {
        int s = K[m][k];
        if (n >> s - 1 & 1) on++;
      }
      if (on != 0 && p == on % 2) l++;
    }
    if (l == M) ans++;
  }
  cout << ans << endl;
  return 0;
}
