#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5, mod = 1e9 + 7;
vector<int> vi[15];
int a[15], p[15];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m, k, x;
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    cin >> k;
    while (k--) {
      cin >> x;
      vi[i].push_back(x);
    }
  }
  for (int i = 1; i <= m; ++i) cin >> p[i];
  int ans = 0;
  for (int i = 1; i < (1 << n); ++i) {
    int pos = 1, t = i;
    while (t) {
      if (t & 1) {
        a[pos] = 1;
      } else
        a[pos] = 0;
      ++pos;
      t >>= 1;
    }
    bool exist = 0;
    for (int i = 1; i <= m; ++i) {
      int cnt = 0;
      for (int j = 0; j < vi[i].size(); ++j) {
        if (a[vi[i][j]]) ++cnt;
      }
      if (cnt % 2 != p[i]) {
        exist = 1;
        break;
      }
    }
    if (!exist) ++ans;
  }
  cout << ans << endl;
  return 0;
}
