#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, i, j, bit, ans1, ans2 = 0, k;
  cin >> n >> m;
  vector<vector<int>> s(m, vector<int>(0));
  for (i = 0; i < m; i++) {
    int t;
    cin >> t;
    for (j = 0; j < t; j++) {
      int p;
      cin >> p;
      s.at(i).push_back(p);
    }
  }
  for (i = 0; i < m; i++) {
    int p;
    cin >> p;
    s.at(i).push_back(p);
  }
  for (bit = 0; bit < (1 << n); bit++) {
    bool judge = true;
    vector<int> p(0);
    int t = 0;
    for (i = 0; i < n; i++) {
      if ((1 << i) & bit) p.push_back(i + 1);
    }
    for (i = 0; i < s.size(); i++) {
      int aaa = 0;
      for (j = 0; j < p.size(); j++) {
        for (k = 0; k < s.at(i).size() - 1; k++) {
          if (p.at(j) == s.at(i).at(k)) aaa++;
        }
      }
      if (((aaa + 1) % 2) == (s.at(i).at(k))) judge = false;
    }
    if (judge) ans2++;
  }
  cout << ans2 << endl;
}
