#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace::std; template void print(const T& v) { for (const auto& x : v) cout << x << " "; cout << endl; } int main() { ios::sync_with_stdio(false); long long n, m, w; cin >> n >> m >> w; vector< long long> dw(n + m); for ( long long i = 0; i < n; ++i) cin >> dw[i]; vector< long long> dv(n + m); for ( long long i = 0; i < n; ++i) cin >> dv[i]; for ( long long i = 0; i < m; ++i) { cin >> dw[n + i]; dw[n + i] = -dw[n + i]; } for ( long long i = 0; i < m; ++i) { cin >> dv[n + i]; dv[n + i] = -dv[n + i]; } vector> d(1 << (n + m), vector(w + 1)); long long r = 0; for ( long long s = 1; s < 1 << (n + m); ++s) for ( long long i = 0; i < n + m; ++i) if (s & (1 << i)) for ( long long pw = 0; pw <= w; ++pw) { long long nw = pw + dw[i]; if (0 <= nw && nw <= w) { d[s][nw] = max(d[s][nw], d[s ^ (1 << i)][pw] + dv[i]); r = max(r, d[s][nw]); } } cout << r << endl; return 0; }