#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  int n, m, k, b, sum = 0;
  cin >> n >> m;
  vector<bitset<10>> a(m);
  vector<int> c(m);
  rep(i,m) {
    cin >> k;
    bitset<10> bs;
    rep(j,k) {
      cin >> b;
      bs.set(b-1);
    }
    a[i] = bs;
  }
  rep(i,m)
  {
    cin >> c[i];
  }
  rep(b,(1 << n)) {
    bitset<10> bit(b);
    rep(i,m)
      if (c[i] != (int) (a[i] & bit).count() % 2) {
        sum--;
        break;
      }
    sum++;
  }
  cout << sum;
}