#include <bits/stdc++.h>
const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
using lint = long long;
using namespace std;
int count_bit(unsigned long long data) {
  data = (data & 0x5555555555555555) + ((data & 0xAAAAAAAAAAAAAAAA) >> 1);
  data = (data & 0x3333333333333333) + ((data & 0xCCCCCCCCCCCCCCCC) >> 2);
  data = (data & 0x0F0F0F0F0F0F0F0F) + ((data & 0xF0F0F0F0F0F0F0F0) >> 4);
  data = (data & 0x00FF00FF00FF00FF) + ((data & 0xFF00FF00FF00FF00) >> 8);
  data = (data & 0x0000FFFF0000FFFF) + ((data & 0xFFFF0000FFFF0000) >> 16);
  data = (data & 0x00000000FFFFFFFF) + ((data & 0xFFFFFFFF00000000) >> 32);
  return data;
}
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> light(m);
  vector<int> light_bit(m);
  for (int i = 0; i < (int)(m); ++i) {
    int k;
    cin >> k;
    light[i].resize(k);
    int bit = 0;
    for (int j = 0; j < (int)(k); ++j) {
      int s;
      cin >> s;
      --s;
      light[i][j] = s;
      bit |= (1 << s);
    }
    light_bit[i] = bit;
  }
  vector<int> p(m);
  for (int i = 0; i < (int)(m); ++i) cin >> p[i];
  int count = 0;
  for (int bit = 1; bit < (1 << n); ++bit) {
    bool flag = true;
    for (int j = 0; j < (int)(m); ++j) {
      if ((count_bit(bit & light_bit[j]) % 2) != p[j]) {
        flag = false;
        break;
      }
    }
    if (flag) ++count;
  }
  cout << count << endl;
  return 0;
}
