#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long o[100];
long long light[100][100];
long long p[100];
string bit(int n, int ppp) {
  string s;
  s.clear();
  int ans;
  stack<int> stk;
  while (n != 0) {
    ans = n % 2;
    n = n / 2;
    stk.push(ans);
  }
  int pp = 0;
  while (!stk.empty()) {
    if (stk.top() == 1)
      s += '1';
    else
      s += '0';
    stk.pop();
  }
  char s1[100];
  for (int i = 0; i < s.length(); i++) s1[i] = s[i];
  reverse(s1, s1 + s.length());
  for (int i = 0; i < s.length(); i++) s[i] = s1[i];
  for (int i = s.length(); i < ppp; i++) s += '0';
  for (int i = 0; i < s.length(); i++) s1[i] = s[i];
  reverse(s1, s1 + s.length());
  for (int i = 0; i < s.length(); i++) s[i] = s1[i];
  return s;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int x;
    cin >> o[i];
    for (int j = 1; j <= o[i]; j++) cin >> light[i][j];
  }
  for (int i = 1; i <= m; i++) cin >> p[i];
  int an = 0;
  for (int i = 0; i <= (1 << n) - 1; i++) {
    bool ok = true;
    string s = bit(i, n);
    for (int j = 1; j <= m; j++) {
      int ans = 0;
      for (int k = 1; k <= o[j]; k++) {
        if (s[light[j][k]] == '1') ans++;
      }
      if (ans % 2 != p[j]) ok = false;
    }
    if (ok) {
      an++;
    }
  }
  cout << an << endl;
}
