#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;
const double pi = 3.141592653589793;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> d;
  for (int i = 0; i < (int)(m); i++) {
    int k;
    cin >> k;
    vector<int> d1;
    for (int j = 0; j < (int)(k); j++) {
      int s;
      cin >> s;
      d1.push_back(s);
    }
    d.push_back(d1);
  }
  int p[m];
  for (int i = 0; i < (int)(m); i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int i = 1; i < (1 << n); i++) {
    bitset<10> s(i);
    int b = 1;
    for (int j = 0; j < m; j++) {
      int c = 0;
      for (int x : d[j]) {
        if (s.test(x - 1)) {
          c += 1;
        }
      }
      if (c % 2 != p[j]) {
        b = 0;
        break;
      }
    }
    if (b) {
      ans += 1;
    }
  }
  cout << ans << endl;
  return 0;
}
