#include <bits/stdc++.h>
const int maxn = 100000;
using namespace std;
priority_queue<int, vector<int>, greater<int>> q;
int b[13];
int c[13];
int d[13][13];
int C(int x, int y) {
  int z = 1;
  for (int i = 1; i <= y; i++) z = z * (x - i + 1) / i;
  return z;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> c[i];
    for (int j = 1; j <= c[i]; j++) cin >> d[i][j], b[d[i][j]] = 1;
  }
  int sum = 1;
  for (int i = 1; i <= m; i++) {
    int a;
    cin >> a;
    if (a & 1) {
      int zz = 0;
      for (int j = 1; j <= c[i]; j += 2) zz += C(c[i], j);
      sum = sum * zz;
    } else {
      int zz = 0;
      for (int j = 2; j <= c[i]; j += 2) zz += C(c[i], j);
      sum = sum * zz;
    }
  }
  int ant = 0;
  for (int i = 1; i <= n; i++)
    if (!b[i]) ant++;
  int x = 1;
  for (int i = 1; i <= ant; i++) x *= 2;
  if (ant) sum = sum * x;
  cout << sum << endl;
}
