#include <bits/stdc++.h>
using namespace std;
int k[20], s[20][20], p[20];
int main(void) {
  int n, m;
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    cin >> k[i];
    for (long long j = 0; j < k[i]; j++) {
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  for (long long i = 0; i < m; i++) cin >> p[i];
  long long cnt = 0;
  for (int sw = 0; sw < (1 << n); sw++) {
    bool all = true;
    for (long long i = 0; i < m; i++) {
      int on = 0;
      for (long long j = 0; j < k[i]; j++) {
        if (sw & (1 << j)) on++;
      }
      if (on % 2 != p[i]) all = false;
    }
    if (all) cnt++;
  }
  cout << cnt << endl;
}
