#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
constexpr long long DINF = 1000000000000;
const double PI = acos(-1);
struct Tll {
  LL first, second, third;
};
struct Fll {
  LL first, second, third, fourth;
};
void YN(bool f) {
  if (f)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
void yn(bool f) {
  if (f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
struct Edge {
  LL to, cost;
};
struct edge {
  LL from, to, cost;
};
vector<vector<Edge>> g;
vector<edge> ed;
vector<pair<LL, LL>> pv;
map<LL, LL> ma;
set<LL> st;
int di[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
LL n, m, k, p, q, w, h, ans, cnt, sum, a[310000], b[310000];
string str[10000];
bool f;
char c[1100][1100];
int main() {
  cin >> n >> m;
  for (LL i = 0; i < m; i++) {
    LL x;
    cin >> x;
    for (LL j = 0; j < x; j++) {
      LL y;
      cin >> y;
      y--;
      a[y] |= (1 << i);
    }
  }
  for (LL i = 0; i < m; i++) {
    LL x;
    cin >> x;
    if (x) sum |= (1 << i);
  }
  for (int mask = 0; mask < 1 << n; mask++) {
    LL cur = 0;
    for (LL i = 0; i < m; i++) {
      if (mask & (1 << i)) cur ^= a[i];
    }
    if (sum == cur) ans++;
  }
  cout << ans << endl;
  return 0;
}
