Time limit
2s
Memory limit
128 MB
Yeonghun collects stickers. There are N different stickers, numbered from 0 to N-1, and exactly one copy of each sticker exists. Each sticker has a price and a value.
Yeonghun initially owns some of the stickers. He may repeatedly sell stickers he owns and buy stickers he does not own. After any number of these actions, he wants the sum of the values of the stickers he owns to be at least K.
Find the minimum amount of money Yeonghun must have at the beginning. If there is no way to reach a total value of at least K, print -1.
The first line contains the integer N, the number of stickers. N is a positive integer not greater than 32.
The second line contains the price of each sticker.
The third line contains the value of each sticker.
The fourth line contains the integer K.
The fifth line contains the number of stickers Yeonghun initially owns.
The sixth line contains the numbers of the stickers Yeonghun initially owns. If he initially owns 0 stickers, the sixth line is not given.
Each price is a positive integer not greater than 30,000,000. The number of initially owned stickers is an integer from 0 to N, inclusive. K is an integer from 0 to 1,000,000,000, inclusive. Each value is an integer from 1 to 30,000,000, inclusive.
Print the minimum required initial amount of money. If it is impossible, print -1.