Ability Draft

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

Dota 2 is a competitive multiplayer computer game. In this game, two teams of nn players are fighting each other in order to destroy the enemy main building, Ancient. Each player controls one hero, and each hero has exactly ss standard abilities and exactly one ultimate ability.

Ability Draft is a fun mode of Dota 2. In this mode, at the start of the game each player gets random hero without abilities at all. Then players pick abilities in certain order from the pool of abilities provided by the game. At his turn, player may either pick any of the remaining standard abilities, or, if he didn't pick his ultimate ability, pick any of the remaining ultimate abilities. The pool contains enough abilities of both kinds so that each player can always pick his ss standard abilities and one ultimate ability.

The strength of the team is the sum of strengths of all abilities of all heroes in this team. All players are picking abilities in such a way that the difference between the strength of their own team and the strength of the enemy team at the end of draft procedure is maximum possible.

Knowing the strengths of abilities in the pool and the order of ability picks, find the difference of strengths of the teams if all players perform their picks optimally.

입력

The first line of input contains two integers nn and ss (1n51 \le n \le 5, 1s31 \le s \le 3) --- the number of players in the team and the number of standard abilities of the heroes.

The second line contains 2n(s+1)2n \cdot (s + 1) indices of players --- the order of ability picks. Each index from 11 to 2n2n appears exactly s+1s + 1 times in this array. Players with indices between 1 and nn belong to the first team, and players with indices between n+1n + 1 and 2n2n belong to the second team. 

The third line contains an integer p_sp\_s (2nsp_s362n \cdot s \le p\_s \le 36) --- the number of standard abilities in the pool.

The fourth line contains p_sp\_s integers from 11 to 10610^6 --- strengths of the standard abilities.

The fifth line contains an integer p_up\_u (2np_u122n \le p\_u \le 12) --- the number of ultimate abilities in the pool.

The sixth line contains p_up\_u integers from 11 to 10610^6 --- strengths of the ultimate abilities.

출력

Output a single integer --- the difference of strengths of the teams after all ability picks.