#include <bits/stdc++.h>
using namespace std;
class light {
 public:
  vector<int> switchs;
  bool evenOrOdd = true;
  void setSwitch(int num) { switchs.push_back(num); }
  void setEvenOrOdd(int num) {
    if (num == 1) {
      evenOrOdd = false;
    }
  }
};
int main() {
  int switchNum, lightNum;
  vector<light> 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].setSwitch(switchIndex);
    }
  }
  for (int i = 0; i < lightNum; i++) {
    int boolNum;
    cin >> boolNum;
    lights[i].setEvenOrOdd(boolNum);
  }
  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].switchs.size(); k++) {
        if (checkerBit & (1 << lights[j].switchs[k] - 1)) onswitch++;
      }
      if ((lights[j].evenOrOdd && (onswitch % 2 == 0)) ||
          (!lights[j].evenOrOdd && (onswitch % 2 == 1))) {
        onLight++;
      }
    }
    if (onLight == lightNum) counter++;
  }
  cout << counter;
  return 0;
}
