# #480. 【NOI2019】序列

$$1 \le c_1 < c_2 < \ldots < c_K \le n , 1 \le d_1 < d_2 < \ldots < d_K \le n$$

$$\Big| \{c_1, c_2, \ldots , c_K\} \cap \{d_1, d_2, \ldots , d_K\} \Big| \ge L$$

$$\sum_{i=1}^K a_{c_i}+\sum_{i=1}^K b_{d_i}$$

### 样例一

#### input

5
1 1 1
7
7
3 2 1
4 1 2
1 4 2
5 2 1
4 5 5 8 4
2 1 7 2 7
6 4 1
1 5 8 3 2 4
2 6 9 3 1 7
7 5 4
1 6 6 6 5 9 1
9 5 3 9 1 4 2

#### output

14
12
27
45
62

### 限制与约定

$1 \sim 3$$10$$3 \times 10^5$
$4, 5$$18 6, 7$$30$
$8 \sim 10$$150 11 \sim 16$$2 \times 10^3$
$17 \sim 21$$2 \times 10^5 22 \sim 25$$10^6$