#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)

signed main() {
  int n, m;
  cin >> n >> m;
  vector<int> sw(n, 0);
  int p = 0, ans = 0;
  rep(i, m) {
    int x;
    cin >> x;
    rep(j, x) {
      int y;
      cin >> y;
      y--;
      sw[y] |= (1 << i);
    }
  }

  rep(i, m) {
    int x;
    cin >> x;
    p |= (x << i);
  }

  rep(bit, 1 << n) {
    int tmp = 0;
    rep(i, n) {
      if ((bit >> i) & 1) tmp ^= sw[i];
    }
    if (tmp == p) ans++;
  }
  cout << ans << endl;
  return 0;
}
