#include <bits/stdc++.h>
using namespace std;

int main() { 
  int n, m, k, s_, ans = 0;
  cin >> n >> m;
  int s[m] = {0}, p[m] = {0};
  for(int i = 0; i < m; ++i) {
    cin >> k;
    for(int j = 0; j < k; ++j) {
      cin >> s_;
      s[i] += pow(2, s_-1);
    }
  }
  for(int i = 0; i < m; ++i) {
    cin >> p[i];
  }

  for(int j = 1; j < (1<<n); ++j) {
    int cm = 0;

    for(int i = 0; i < m; ++i) {
      int bit = j & s[i];
      int on = 0;

      while(bit) {
        if(bit%2 == 1) on++;
        bit >>= 1;
      }

      if(p[i] == on%2) {
        cm++;
      } else {
        break;
      }
    }

    if(cm == m) {
      ans++;
    }
  }
  cout << ans << '\n';
}
