Cache

Choose which cached objects to evict for a known request sequence of sized objects with load costs to minimize total reload cost.

Medium7Dynamic programmingBit manipulationNo attempts yetTime limit1sMemory limit256 MB

Problem

A system uses NN objects of different sizes. The system can use an object only while the object is in the cache. If a requested object is not in the cache, it must be put there first, and other objects may be deleted beforehand to free enough room. An object of size SiS_i fits as soon as the total free space in the cache is at least SiS_i. Putting object ii into the cache costs WiW_i, and deleting an object from the cache costs 0. The cache holds any set of objects whose total size is at most CC. The cache is empty at the start, and an object may be put into the cache only at the moment it is requested. You know the order in which the system uses the objects. Decide which objects to delete and when to delete them so that the total cost of putting objects into the cache is as small as possible.

Input

The first line contains three integers NN, CC and KK (1N181 \le N \le 18, 1C1091 \le C \le 10^9, 1K1001 \le K \le 100), where KK is the number of requests.

The second line contains NN integers S1,S2,,SNS_1, S_2, \dots, S_N, the sizes of the objects (1SiC1 \le S_i \le C).

The third line contains NN integers W1,W2,,WNW_1, W_2, \dots, W_N, the cost of putting each object into the cache (0Wi1060 \le W_i \le 10^6).

The fourth line contains KK object numbers in the order the system uses them. Each number is between 1 and NN. Numbers on one line are separated by spaces.

Output

Print the minimum total cost of putting objects into the cache on the first line. Then print KK lines. Line ii lists the objects deleted from the cache right before the ii-th requested object is used. The first number on the line is the count mm of deleted objects, followed by the mm object numbers. Numbers on one line are separated by spaces.

Several deletion plans can reach the minimum cost, so print the one picked by these rules. Write the object numbers on each line in increasing order. Read everything after the first line as a single sequence of numbers, taken line by line, and among the plans of minimum total cost print the one whose sequence comes first in lexicographic order. Because the first number on each line is the count, this plan deletes nothing when the requested object is already in the cache or still fits in the free space.