#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long double PI = acos(-1);
const long double EPS = 0.0000000001;
const long long LINF = 1001002003004005006ll;
const int INF = 1001001001;
int main() {
  int n, m;
  cin >> n >> m;
  vector<bool> sw(n);
  vector<vector<bool>> light(m, vector<bool>(n, false));
  for (long long i = 0; i < (long long)(m); i++) {
    int k;
    cin >> k;
    for (long long j = 0; j < (long long)(k); j++) {
      int x;
      cin >> x;
      x--;
      light[i][x] = true;
    }
  }
  vector<long long> p(m);
  for (long long i = 0; i < (long long)(m); i++) cin >> p[i];
  long long res = 0;
  for (long long i = 0; i < (long long)(1 << n); i++) {
    bool flag = true;
    int cnt = 0;
    for (long long j = 0; j < (long long)(m); j++) {
      for (long long bit = 0; bit < (long long)(n); bit++) {
        if (i & 1 << bit)
          if (light[j][bit]) cnt += 1;
      }
      if (!cnt || cnt % 2 != p[j]) flag = false;
    }
    if (flag) res += 1;
  }
  cout << res << endl;
}
