#include <bits/stdc++.h>
using namespace std;
char _buf[100000], *_op(_buf), *_ed(_buf);
inline int getint() {
  int _s = 0;
  char _ch = (_op == _ed && (_ed = (_op = _buf) + fread(_buf, 1, 100000, stdin),
                             _op == _ed)
                  ? EOF
                  : *_op++);
  while (!('0' <= _ch && _ch <= '9'))
    _ch = (_op == _ed && (_ed = (_op = _buf) + fread(_buf, 1, 100000, stdin),
                          _op == _ed)
               ? EOF
               : *_op++);
  while (('0' <= _ch && _ch <= '9'))
    _s = _s * 10 + _ch - 48,
    _ch = (_op == _ed && (_ed = (_op = _buf) + fread(_buf, 1, 100000, stdin),
                          _op == _ed)
               ? EOF
               : *_op++);
  return _s;
}
const int N = 1e5 + 1, INF = 0x3f3f3f3f;
inline int min(const int& x, const int& y) { return (x - y >> 31) ? x : y; }
queue<int> q;
int n, m, g, tot = 1, S, T, ans, sum;
int a[N], h[N], c[N], dis[N], cnt[N];
struct edge {
  int t, n, w;
} e[N];
inline void add_edge(int x, int y, int w) {
  e[++tot] = (edge){y, h[x], w}, h[x] = tot;
  e[++tot] = (edge){x, h[y], 0}, h[y] = tot;
}
inline void input() {
  n = getint(), m = getint(), g = getint(), S = n + m + 1, T = S + 1;
  for (int i = 1; i <= n; i++) a[i] = getint();
  for (int i = 1; i <= n; i++)
    if (a[i])
      add_edge(i, T, getint());
    else
      add_edge(S, i, getint());
  int opt, w, k;
  for (int i = 1; i <= m; i++)
    if (getint()) {
      ans += w = getint(), k = getint();
      while (k--) add_edge(getint(), i + n, INF);
      add_edge(i + n, T, w + getint() * g);
    } else {
      ans += w = getint(), k = getint();
      while (k--) add_edge(i + n, getint(), INF);
      add_edge(S, i + n, w + getint() * g);
    }
}
inline int bfs() {
  for (int i = 1; i <= T; i++) dis[i] = cnt[i] = 0;
  q.push(T), dis[T] = 1;
  for (int u; !q.empty(); q.pop())
    for (int i = h[u = q.front()], v; v = e[i].t, i; i = e[i].n)
      if (e[i ^ 1].w && !dis[v]) dis[v] = dis[u] + 1, q.push(v);
  for (int i = 1; i <= T; i++) cnt[dis[i]]++;
  return dis[S];
}
inline int dfs(int u, int res) {
  if (u == T) return res;
  int f, out = 0;
  for (int &i = c[u], v; v = e[i].t, i; i = e[i].n)
    if (dis[u] == dis[v] + 1 && e[i].w) {
      f = dfs(v, min(res, e[i].w)), e[i].w -= f, e[i ^ 1].w += f, res -= f,
      out += f;
      if (!res) return out;
    }
  if (!--cnt[dis[u]++]) dis[S] = T + 1;
  return cnt[dis[u]]++, out;
}
inline void work() {
  while (bfs())
    while (dis[S] <= T) copy(h + 1, h + 1 + T, c + 1), ans -= dfs(S, INF);
  cout << ans;
}
int main() {
  input();
  work();
  return 0;
}
