#include <bits/stdc++.h>
using namespace std;
const int maxn = 20;
int sz[maxn], maz[maxn][maxn], p[maxn], bir[maxn];
bool on[maxn];
int main() {
  freopen("in.txt", "r", stdin);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> sz[i];
    for (int j = 1; j <= sz[i]; j++) {
      cin >> maz[i][j];
      maz[i][j]--;
    }
  }
  for (int i = 1; i <= m; i++) cin >> p[i];
  bir[0] = 1;
  for (int i = 1; i <= 12; i++) bir[i] = bir[i - 1] << 1;
  int ans = 0;
  for (int st = 0; st < bir[n]; st++) {
    for (int i = 0; i < n; i++) on[i] = !!(st & bir[i]);
    bool flag = true;
    for (int i = 1; i <= m; i++) {
      int now = 0;
      for (int j = 1; j <= sz[i]; j++)
        if (on[maz[i][j]]) now ^= 1;
      if (now != p[i]) {
        flag = false;
        break;
      }
    }
    if (flag) ans++;
  }
  cout << ans << endl;
  return 0;
}
