#include <bits/stdc++.h>
using namespace std;
map<int, bool> switches;
vector<int> v[15];
int k[11];
int bulb[11];
int ans;
int n, m;
void dfs(int x) {
  int res = 1, cnt = 0;
  if (x == n) {
    for (int i = 0; i < m; i++) {
      cnt = 0;
      for (int j = 0; j < k[i]; j++) {
        if (switches[v[i][j] - 1]) cnt++;
      }
      if (cnt % 2 != bulb[i]) res = 0;
    }
    ans += res;
  } else {
    switches[x] = true;
    dfs(x + 1);
    switches[x] = 0;
    dfs(x + 1);
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      int x;
      cin >> x;
      v[i].push_back(x);
    }
  }
  for (int i = 0; i < m; i++) cin >> bulb[i];
  dfs(0);
  cout << ans << endl;
  return 0;
}
