#include using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } int main() { fast_io(); int n, m, W; cin >> n >> m >> W; vector a(n), c(m); vector b(n), d(m); for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { cin >> b[i]; } for (int i = 0; i < m; i++) { cin >> c[i]; } for (int i = 0; i < m; i++) { cin >> d[i]; } vector> dp(1 << (n + m), vector(W + 1, -4e18)); dp[0][0] = 0; for (int msk = 0; msk < (1 << (n + m)); msk++) { for (int w = 0; w <= W; w++) { for (int i = 0; i < (n + m); i++) { if (msk & (1 << i)) { continue; } int msk_new = msk | (1 << i); int w_new = w + (i < n ? a[i] : -c[i - n]); long long dp_new = dp[msk][w] + (i < n ? b[i] : -d[i - n]); if (w_new <= W && w_new >= 0) { dp[msk_new][w_new] = max(dp[msk_new][w_new], dp_new); } } } } long long ans = 0; for (int i = 0; i < (1 << (n + m)); i++) { for (int j = 0; j <= W; j++) { ans = max(ans, dp[i][j]); } } cout << ans << endl; }