#include <bits/stdc++.h>
using namespace std;
vector<int> sw[60];
int n, m, ans;
int p[60], temp[60];
bool vis[60];
void dfs(int x) {
  if (x == n + 1) {
    memset(temp, 0, sizeof(temp));
    for (int i = 1; i <= n; i++) {
      if (!vis[i]) continue;
      for (int j = 0; j < sw[i].size(); j++) {
        int b = sw[i][j];
        temp[b]++;
      }
    }
    for (int i = 1; i <= m; i++)
      if (temp[i] % 2 != p[i]) return;
    ans++;
    return;
  }
  dfs(x + 1);
  vis[x] = true;
  dfs(x + 1);
  vis[x] = false;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int t;
      cin >> t;
      sw[t].push_back(i);
    }
  }
  for (int i = 1; i <= m; i++) cin >> p[i];
  dfs(1);
  return 0;
}
