#include <bits/stdc++.h>
using namespace std;
const int N = 12500;
const int M = 70050;
const int inf = 1 << 29;
struct Edge {
  int nxt, to, ci;
} e[M];
int h[N], e_num = 1;
void add(int from, int to, int ci) {
  e[++e_num] = (Edge){h[from], to, ci};
  h[from] = e_num;
}
void _add(int u, int v, int ci) {
  add(u, v, ci);
  add(v, u, 0);
}
int d[N], maxflow;
queue<int> q;
int n, m, S, T, tot;
int zt[N], v[N], g;
bool bfs() {
  memset(d, 0, sizeof(d));
  while (!q.empty()) q.pop();
  d[S] = 1;
  q.push(S);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = h[u]; i; i = e[i].nxt) {
      int v = e[i].to;
      if (!d[v] && e[i].ci) {
        d[v] = d[u] + 1;
        if (v == T) return 1;
        q.push(v);
      }
    }
  }
  return 0;
}
int dinic(int u, int flow) {
  if (u == T) return flow;
  int ret = flow, k;
  for (int i = h[u]; i && ret; i = e[i].nxt) {
    int v = e[i].to;
    if (e[i].ci && d[v] == d[u] + 1) {
      k = dinic(v, min(ret, e[i].ci));
      if (!k) d[v] = 0;
      ret -= k;
      e[i].ci -= k;
      e[i ^ 1].ci += k;
    }
  }
  return flow - ret;
}
int rnm[15];
int main() {
  scanf("%d%d%d", &n, &m, &g);
  S = n + 1;
  tot = T = n + 2;
  for (int i = 1; i <= n; i++) scanf("%d", &zt[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &v[i]);
  for (int i = 1; i <= n; i++) {
    if (zt[i])
      _add(i, T, v[i]);
    else
      _add(S, i, v[i]);
  }
  int sum = 0, fri, op, w, K;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &op, &w, &K);
    for (int j = 1; j <= K; j++) scanf("%d", &rnm[j]);
    scanf("%d", &fri);
    tot++;
    sum += w;
    if (op) {
      for (int j = 1; j <= K; j++) _add(rnm[j], tot, inf);
      _add(tot, T, w + fri * g);
    } else {
      for (int j = 1; j <= K; j++) _add(tot, rnm[j], inf);
      _add(S, tot, w + fri * g);
    }
  }
  int fl;
  while (bfs())
    while (fl = dinic(S, inf)) maxflow += fl;
  printf("%d", sum - maxflow);
  return 0;
}
