#include <bits/stdc++.h>
using namespace std;
const int N = 1e4, inf = (1 << 29), M = 2000;
struct EDGE {
  int to, lim;
  EDGE *nxt, *rev;
} * cpy[N + M + 10];
struct FLOWGRAPH {
  EDGE edg[3 * (N + M * 10 + M)], *ncnt, *top[N + M + 10];
  FLOWGRAPH() { ncnt = edg; }
  void AddEdge(int u, int v, int lim) {
    EDGE *p = ++ncnt, *q = ++ncnt;
    *p = (EDGE){v, lim, top[u], q};
    top[u] = p;
    *q = (EDGE){u, 0, top[v], p};
    top[v] = q;
  }
} Gflw;
int n, m, Vg, Ps, Pt, Vtot;
int Cs[N + 3], Cv[N + 3], Cp[N + 3], rnk[N + M + 10];
bool BFS() {
  for (int i = 1; i <= Pt; i++) rnk[i] = 0;
  queue<int> que;
  que.push(Ps);
  rnk[Ps] = 1;
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    for (EDGE *it = Gflw.top[u]; it; it = it->nxt) {
      int v = it->to;
      if (!it->lim || rnk[v]) continue;
      rnk[v] = rnk[u] + 1;
      if (v == Pt) return true;
      que.push(v);
    }
  }
  return rnk[Pt] != 0;
}
int GetFlow(int u, int flwin) {
  if (u == Pt) return flwin;
  int flwout = 0;
  for (EDGE *it = cpy[u]; it; it = it->nxt) {
    cpy[u] = it;
    int v = it->to;
    if (!it->lim || rnk[v] != rnk[u] + 1) continue;
    int flwv = GetFlow(v, min(flwin - flwout, it->lim));
    it->lim -= flwv;
    it->rev->lim += flwv;
    flwout += flwv;
    if (flwout == flwin) break;
  }
  return flwout;
}
int Dinic() {
  int ret = 0;
  while (BFS()) {
    memcpy(cpy, Gflw.top, sizeof Gflw.top);
    ret += GetFlow(Ps, inf);
  }
  return ret;
}
int main() {
  scanf("%d%d%d", &n, &m, &Vg);
  Ps = n + m + 1;
  Pt = n + m + 2;
  for (int i = 1; i <= n; i++) scanf("%d\n", &Cs[i]);
  for (int i = 1; i <= n; i++) scanf("%d\n", &Cv[i]);
  for (int i = 1; i <= n; i++) {
    if (Cs[i])
      Gflw.AddEdge(Ps, i, Cv[i]);
    else
      Gflw.AddEdge(i, Pt, Cv[i]);
  }
  for (int i = 1; i <= m; i++) {
    int Vs, Vw, Vn, Vt;
    scanf("%d%d%d", &Vs, &Vw, &Vn);
    Vtot += Vw;
    for (int j = 1; j <= Vn; j++) scanf("%d", &Cp[j]);
    scanf("%d", &Vt);
    if (Vs) {
      if (Vt)
        Gflw.AddEdge(Ps, n + i, Vw + Vg);
      else
        Gflw.AddEdge(Ps, n + i, Vw);
      for (int j = 1; j <= Vn; j++) Gflw.AddEdge(n + i, Cp[j], inf);
    } else {
      if (Vt)
        Gflw.AddEdge(n + i, Pt, Vw + Vg);
      else
        Gflw.AddEdge(n + i, Pt, Vw);
      for (int j = 1; j <= Vn; j++) Gflw.AddEdge(Cp[j], n + i, inf);
    }
  }
  printf("%d\n", Vtot - Dinic());
  return 0;
}
