#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m;
  cin >> n >> m;
  long long int k, l, p[m];
  long long int s[m][n];
  for (long long int i = 0; i < m; i++)
    for (long long int j = 0; j < n; j++) s[i][j] = 0;
  for (long long int i = 0; i < m; i++) {
    cin >> k;
    for (long long int j = 0; j < k; j++) {
      cin >> l;
      s[i][l - 1] = 1;
    }
  }
  for (long long int i = 0; i < m; i++) cin >> p[i];
  long long int fl, ans = 0;
  for (long long int i = 1; i < (1 << n); i++) {
    fl = 0;
    for (long long int k = 0; k < m; k++) {
      long long int sum = 0;
      for (long long int j = 0; j < n; j++) {
        if (i & (1 << j)) {
          if (s[k][j] == 1) sum++;
        }
      }
      if (sum % 2 != p[k]) {
        fl = 1;
        break;
      }
    }
    if (fl == 0) ans++;
  }
  cout << ans << endl;
}
