#include <bits/stdc++.h>
using namespace std;
int main() {
  int switchNum, lightNum;
  vector<vector<int>> lights(lightNum);
  cin >> switchNum >> lightNum;
  for (int i = 0; i < lightNum; i++) {
    int switchsOfLight;
    cin >> switchsOfLight;
    for (int j = 0; j < switchsOfLight; j++) {
      int switchIndex;
      cin >> switchIndex;
      lights[i].push_back(switchIndex);
    }
  }
  for (int i = 0; i < lightNum; i++) {
    int evenOrOdd;
    cin >> evenOrOdd;
    lights[i].push_back(evenOrOdd);
  }
  int checkerBit;
  int bitMax = pow(2, switchNum);
  int counter = 0;
  for (checkerBit = 0; checkerBit < bitMax; checkerBit++) {
    int onLight = 0;
    for (int j = 0; j < lightNum; j++) {
      int onswitch = 0;
      for (int k = 0; k < lights[j].size() - 1; k++) {
        if (checkerBit & (1 << lights[j][k] - 1)) onswitch++;
      }
      if (onswitch % 2 == lights[j].back()) {
        onLight++;
      }
    }
    if (onLight == lightNum) counter++;
  }
  cout << counter;
  return 0;
}
