#include <bits/stdc++.h>
using namespace std;
struct arr {
  string name;
  int point;
  int num;
};
int ans = 0;
vector<arr> arrs;
int main() {
  int n = 0;
  int b;
  int l, s;
  int p[10];
  string a;
  cin >> l;
  cin >> s;
  for (int i = 0; i < (int)(s); i++) {
    int a;
    cin >> a;
    for (int j = 0; j < (int)(a); j++) {
      int s;
      cin >> s;
      p[i] += exp2((double)(s - 1));
    }
  }
  int k[10];
  for (int i = 0; i < (int)(s); i++) {
    cin >> k[i];
  }
  for (int i = 0; i < (int)(exp2((double)l)); i++) {
    int anss = 0;
    for (int j = 0; j < (int)(s); j++) {
      if ((__builtin_popcount(p[j] & i) % 2) == k[j]) {
        anss++;
      }
    }
    if (anss == s) {
      ans++;
    }
  }
  cout << ans << endl;
}
