#include <bits/stdc++.h>
using namespace std;
struct MyStruct {
  int idx, pts;
  string name;
};
bool comp(const MyStruct& s, const MyStruct& t) {
  if (s.name != t.name) return s.name < t.name;
  return s.pts > t.pts;
}
int main() {
  int n, m;
  cin >> n >> m;
  int s[10][10] = {};
  for (int i = 0; i < (m); ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < (k); ++j) {
      cin >> s[i][j];
    }
  }
  vector<int> p(m);
  for (int i = 0; i < (m); ++i) {
    cin >> p[i];
  }
  int sum;
  int ans = 0;
  bool flag = 1;
  for (int i = 0; i < (pow(2, n)); ++i) {
    bitset<10> b(i);
    flag = 1;
    for (int y = 0; y < (m); ++y) {
      sum = 0;
      for (int x = 0; x < (10); ++x) {
        if (s[x][y] == 0) {
          break;
        } else {
          if (b[s[x][y] - 1]) {
            sum++;
          }
        }
      }
      if (sum % 2 != p[y]) {
        flag = 0;
      }
    }
    if (flag == 1) {
      ans++;
    }
  }
  cout << (ans) << endl;
  return 0;
}
