#include using namespace std; using pii = pair; int main() { int n, m, w; cin >> n >> m >> w; vector item(n + m); for(int i = 0; i < n; i ++) cin >> item[i].first; for(int i = 0; i < n; i ++) cin >> item[i].second; for(int i = 0; i < m; i ++) cin >> item[i + n].first; for(int i = 0; i < m; i ++) { cin >> item[i + n].second; item[i + n].first *= -1; item[i + n].second *= -1; } auto lb = [](int x) {return x & (-x);}; auto at = [](int x) {int ret = -1; while(x > 0) {x >>= 1; ret ++;} return ret;}; vector weight(1 << (n + m)), dp(1 << (n + m), -1e9); dp[0] = 0; int tot = -1e9; for(int i = 1; i < (1 << (n + m)); i ++) { weight[i] = weight[i - lb(i)] + item[at(lb(i))].first; if(weight[i] >= 0 && weight[i] <= w) { for(int j = i; j; j -= lb(j)) dp[i] = max(dp[i], dp[i ^ lb(j)] + item[at(lb(j))].second); tot = max(tot, dp[i]); } } cout << tot; }