Card
题号:NC244820
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld

题目描述

There are N cards on the table , the value of the i-th () card is a_i .

You need to perform the following operation exactly K times .

Choose a card i () , and change it's value to b_i . Please notice that you can not choose one card twice .

We prepared Q questions for you , each question is :

Firstly read M , and then read M integers id_1,id_2,...,id_M . If you can not choose cards id_1,id_2,...,id_M , what is the maximum sum of the card's values after you perform the operations above .

输入描述:

There are two positive integers  in the first line .

The second line has N positive integers indicates .

The third line has N positive integers indicates .

Then an positive integer in a new line .

Then Q line follows , each line begins with an integer , then M integers indicates id_1,id_2,...,id_M ( if ) .

Two adjacent integers in the same line are separated by a space .

The sum of M in Q queries is less than or equal to .

输出描述:

For each question , print an integer in one line indicates the answer .
示例1

输入

复制
5 1
1 2 3 4 5
5 4 3 2 1
3
1 5
2 1 2
2 1 3

输出

复制
19
15
17