#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int k[10];
  int s[10][10];
  int p[10];
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int count = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    bool judge = true;
    for (int i = 0; i < m; i++) {
      int c = 0;
      for (int j = 0; j < k[i]; j++) {
        int check = s[i][j];
        if (bit & (1 << check)) c++;
      }
      if ((c % 2) != p[i]) judge = false;
    }
    if (judge) count++;
  }
  cout << count << endl;
}
