#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m;
  cin >> n >> m;
  int ret = 0;
  vector<vector<bool>> map(m, vector<bool>(n));
  vector<int> p(m);
  for (int i = 0; i < (int)(m); i++) {
    int t;
    cin >> t;
    for (int j = 0; j < (int)(t); j++) {
      int d;
      cin >> d;
      map[i][d - 1] = true;
    }
  }
  for (int i = 0; i < (int)(m); i++) cin >> p[i];
  for (int bit = 0; bit < (1 << n); bit++) {
    bool isclear = true;
    for (int i = 0; i < (int)(m); i++) {
      int denkyugaONnokazu = 0;
      for (int j = 0; j < (int)(n); j++) {
        if ((map[i][j] == true) && (bit & (1 << j + 1))) {
          denkyugaONnokazu++;
        }
      }
      if (denkyugaONnokazu % 2 != p[i]) {
        isclear = false;
        break;
      }
    }
    if (isclear) ret++;
  }
  cout << ret << endl;
  return 0;
}
