#include <bits/stdc++.h>
using namespace std;
const int N = 15;
int n, m, k[N], s[N][N], p[N], t[N], ans;
void dfs(int cur) {
  if (cur == n + 1) {
    int tot = 0;
    for (int i = 1; i <= m; i++) {
      for (int j = 1; j <= k[i]; j++) tot += t[s[i][j]];
      if (tot % 2 != p[i]) return;
    }
    ans++;
    return;
  }
  t[cur] = 0;
  dfs(cur + 1);
  t[cur] = 1;
  dfs(cur + 1);
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> k[i];
    for (int j = 1; j <= k[i]; j++) cin >> s[i][j];
  }
  for (int i = 1; i <= m; i++) cin >> p[i];
  dfs(1);
  return cout << ans, 0;
}
