#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int, int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int mod = 10000007;
const int inf = 1001001001;
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<set<int>> a(m);
  for (int i = 0; i < (int)(m); i++) {
    int p;
    cin >> p;
    for (int j = 0; j < (int)(p); j++) {
      int q;
      cin >> q;
      a[i].insert(q);
    }
  }
  vi s(m);
  for (int i = 0; i < (int)(m); i++) cin >> s[i];
  int cnt = 0;
  for (int tmp = 0; tmp < (1 << n); tmp++) {
    vi hikaku(m, 0);
    bitset<10> an(tmp);
    for (int i = 0; i < n; i++) {
      if (an.test(i)) {
        for (int j = 0; j < (int)(m); j++) {
          if (a[j].count(i + 1)) hikaku[j]++;
        }
      }
    }
    if (tmp == 5)
      for (int j = 0; j < (int)(m); j++)
        cout << tmp << " " << hikaku[j] << endl;
    bool ok = true;
    for (int j = 0; j < (int)(m); j++) {
      if (hikaku[j] % 2 != s[j]) {
        ok = false;
      }
    }
    if (ok) {
      cnt++;
    }
  }
  cout << cnt << endl;
}
