#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> k(m), p(m);
  int s[10][10];
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < m; i++) cin >> p[i];
  int count = 0;
  for (int sw = 0; sw < 1 << n; sw++) {
    int cc = 0;
    for (int i = 0; i < m; i++) {
      int c = 0;
      for (int j = 0; j < k[i]; j++) {
        if (sw >> j & 1) c++;
      }
      if (c % 2 != p[i])
        break;
      else
        cc++;
    }
    if (cc == m) count++;
  }
  cout << count << endl;
}
