#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
inline void judge() {
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
}
const int maxn = 40005;
int head[maxn], t[maxn << 3], ne[maxn << 3], sap[maxn << 3], num;
const int inf = 1 << 30;
inline void addedge(int x, int y, int z) {
  ne[++num] = head[x];
  head[x] = num;
  t[num] = y;
  sap[num] = z;
  ne[++num] = head[y];
  head[y] = num;
  t[num] = x;
  sap[num] = 0;
}
int cnt[maxn], cur[maxn], his[maxn], in[maxn], out[maxn], S, T, SS, TT,
    edge[maxn], pre[maxn], d[maxn];
inline int isap() {
  for (int i = (1); i <= (T); i++) cur[i] = head[i], d[i] = 0, cnt[i] = 0;
  cnt[0] = T;
  int i = S, aug = inf, ans = 0, jl, minnum;
  while (d[S] < T) {
    his[i] = aug;
    bool flag = 0;
    for (int j = cur[i]; j != -1; j = ne[j])
      if (sap[j] && d[t[j]] + 1 == d[i]) {
        flag = 1;
        aug = min(aug, sap[j]);
        pre[t[j]] = i;
        edge[i] = j;
        cur[i] = j;
        i = t[j];
        if (i == T) {
          ans += aug;
          while (i != S) {
            i = pre[i];
            sap[edge[i]] -= aug;
            sap[edge[i] ^ 1] += aug;
          }
          aug = inf;
        }
        break;
      }
    if (flag) continue;
    minnum = T;
    for (int j = head[i]; j != -1; j = ne[j])
      if (sap[j] && d[t[j]] < minnum) minnum = d[t[j]], jl = j;
    if (--cnt[d[i]] == 0) return ans;
    cnt[d[i] = minnum + 1]++;
    cur[i] = jl;
    if (i != S) {
      i = pre[i];
      aug = his[i];
    }
  }
  return ans;
}
int v[maxn], sex[maxn], n, m, g, nd[maxn];
int main() {
  read(n);
  read(m);
  read(g);
  num = 1;
  for (int i = (1); i <= (n); i++) read(sex[i]);
  for (int i = (1); i <= (n); i++) read(v[i]);
  S = n + m + 1;
  T = n + m + 2;
  for (int i = (1); i <= (T); i++) head[i] = -1;
  for (int i = (1); i <= (n); i++)
    if (sex[i])
      addedge(i, T, v[i]);
    else
      addedge(S, i, v[i]);
  int res = 0;
  for (int i = (1); i <= (m); i++) {
    int w, c, k;
    read(c);
    read(w);
    read(k);
    res += w;
    for (int i = (1); i <= (k); i++) read(nd[i]);
    int v;
    read(v);
    v *= g;
    if (c)
      addedge(i + n, T, v + w);
    else
      addedge(S, i + n, v + w);
    for (int j = (1); j <= (k); j++)
      if (!c)
        addedge(i + n, nd[j], inf);
      else
        addedge(nd[j], i + n, inf);
  }
  res -= isap();
  cout << res;
  return 0;
}
