PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#TP0000029. Rồng xứ Loowater (Dragon of Loowater)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Rồng xứ Loowater (Dragon of Loowater)

Dragon of Loowater

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

A dragon in Loowater has nn heads; head ii has diameter aia_i centimetres. The kingdom has mm knights, and knight jj is bjb_j centimetres tall.

A knight can chop off a head only if its diameter is no greater than the knight's height. Each knight can be hired at most once, and hiring knight jj costs exactly bjb_j gold coins. Find the minimum total cost of chopping off every head. If this is impossible, print exactly Loowater is doomed!.

Input

  • The first line contains n,mn,m, the number of dragon heads and the number of knights.
  • Each of the next nn lines contains an integer aia_i, the diameter in centimetres of head ii.
  • Each of the final mm lines contains an integer bjb_j, the height in centimetres of knight jj.

Output

Print one integer, the minimum cost; if the task is impossible, print exactly Loowater is doomed!.

Subtasks

  • Subtask 1 (20 points): 1≤n,m≤61\le n,m\le 6; 1≤ai,bj≤200001\le a_i,b_j\le20000 for every element.
  • Subtask 2 (30 points): 1≤n,m≤14001\le n,m\le 1400; 1≤ai,bj≤200001\le a_i,b_j\le20000 for every element.
  • Subtask 3 (50 points): 1≤n,m≤200001\le n,m\le 20000; 1≤ai,bj≤200001\le a_i,b_j\le20000 for every element.

Examples

Input

2 3
5
4
7
8
4

Output

11

Explanation

The dragon heads have diameters 55 and 44. The knight of height 44 can chop off the size-44 head and costs 44 coins. The knight of height 77 can chop off the size-55 head and costs 77 coins. The total is 4+7=114+7=11. Using the knight of height 88 would be more expensive.