#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using mp = map<string, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m + 1);
  vector<int> P(m);
  for (int i = 0; i < m; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int x;
      cin >> x;
      x--;
      s[j].push_back(x);
    }
  }
  for (int i = 0; i < m; ++i) {
    cin >> P[i];
  }
  int ans = 0;
  for (int i = 0; i < (1 << n); ++i) {
    bool ok = true;
    for (int j = 0; j < m; ++j) {
      int cnt = 0;
      for (auto& p : s[j]) {
        if ((i >> p) & 1) {
          cnt++;
        }
      }
      if (cnt % 2 == 0) {
        ok = false;
      }
    }
    if (ok) {
      ans++;
    }
  }
  cout << ans << "\n";
  return 0;
}
