#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n = 0;
  int m = 0;
  int q = 0;
  int c = 0;
  cin >> n >> m;
  vector<int> l(n);
  vector<int> k(n);
  vector<int> p(n);
  for (int i = 1; i <= m; i++) {
    cin >> l[i];
    for (int o = 1; o <= l[i]; o++) {
      cin >> c;
      k[i] += c;
    }
  }
  for (int i = 1; i <= m; i++) {
    cin >> p[i];
  }
  for (int i = 1; i <= m; i++) {
    for (int o = 1; o <= l[i]; o++) {
      if (p[i] == k[i] % 2) {
        q++;
      }
    }
  }
  cout << q;
}
