#include <bits/stdc++.h>
using namespace std;
const long long maxn = 200005;
const long long MOD = 998244353;
double mypow(long long a, long long b) {
  double res = 1;
  while (b) {
    if (b & 1) res = res * a;
    a = a * a;
    b >>= 1;
  }
  return res;
}
long long t, n, m;
vector<int> bul[15];
bool mo[15];
bool choose[15];
bool now[15];
long long ans = 0;
void dfs(int index) {
  if (index == n + 1) {
    bool flag = true;
    for (long long i = 1; i <= ((long long)m); i++) {
      if (flag == false) break;
      bool num = 0;
      for (auto j : bul[i])
        if (choose[j]) num = !num;
      if (num ^ mo[i] == 0) flag = false;
    }
    if (flag) ans++;
    return;
  }
  choose[index] = 1;
  dfs(index + 1);
  choose[index] = 0;
  dfs(index + 1);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  while (cin >> n >> m) {
    for (long long i = 1; i <= ((long long)m); i++) {
      cin >> t;
      while (t--) {
        int x;
        cin >> x;
        bul[i].push_back(x);
      }
    }
    for (long long i = 1; i <= ((long long)m); i++) cin >> mo[i];
    ans = 0;
    dfs(1);
    cout << ans << "\n";
  }
  return 0;
}
