import std; void main(){ auto input = readln.split.to!(int[]); auto N = input[0]; auto M = input[1]; auto W = input[2]; int[] w = readln.split.to!(int[]); int[] v = readln.split.to!(int[]); w ~= readln.split.to!(int[]).map!(a => -a).array; v ~= readln.split.to!(int[]).map!(a => -a).array; auto pat = new bool[(2 ^^ (N + M))]; pat[0] = true; auto q = DList!int(0); auto result = 0; while(!q.empty){ auto n = q.front; q.removeFront; auto a = 0; auto b = 0; for(auto i = 0; i < N + M; i++){ if(((n >> i) & 1) == 0) continue; a += v[i]; b += w[i]; } if(a > result){ result = a; } for(auto i = 0; i < N + M; i++){ if(((n >> i) & 1) == 1) continue; if(b + w[i] < 0 || b + w[i] > W) continue; if(pat[n | (1 << i)]) continue; pat[n | (1 << i)] = true; q.insertBack(n | (1 << i)); } } result.writeln; }