#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int swbin[m];
  int p[m];
  for (int i = 0; i < m; i++) {
    bitset<10> a;
    int k;
    cin >> k;
    int s[k];
    for (int j = 0; j < k; j++) {
      cin >> s[j];
      a.set(s[j] - 1);
    }
    swbin[i] = a.to_ullong();
  }
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int cnt1 = 0;
  for (int i = 0; i < (1 << n); i++) {
    bitset<10> s(i);
    int cnt = 0;
    bool c = 1;
    for (int j = 0; j < m; j++) {
      bitset<10> p(swbin[j]);
      cnt = (p & s).count();
      if (cnt % 2 != p[j]) c = 0;
    }
    if (c) cnt1++;
  }
  cout << cnt1 << endl;
}
