#include <bits/stdc++.h>
using namespace std;
const long long LINF = 1e18L + 1;
const int INF = 1e9 + 1;
bool on[11];
int n, m;
bitset<11> switches[11];
bitset<11> p;
long long ans = 0;
void dfs(int k = 0) {
  if (k == n) {
    bitset<11> t = p;
    for (int i = 0; i < (n); ++i) {
      if (on[i]) t ^= switches[i];
    }
    for (int i = 0; i < (m); ++i) {
      if (t[i] != 0) return;
    }
    ans++;
    return;
  }
  dfs(k + 1);
  on[k] = true;
  dfs(k + 1);
  on[k] = false;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < (m); ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < (k); ++j) {
      int s;
      cin >> s;
      s--;
      switches[i][s] = 1;
    }
  }
  for (int i = 0; i < (m); ++i) {
    int hoge;
    cin >> hoge;
    p[i] = hoge;
  }
  dfs();
  cout << ans << endl;
  return 0;
}
