lss3.card - A well-known card problem


Version: v5

Submit Problemset 2000ms / 262144 KB
Difficulty:1.0x

Statement

This is supposed to be Problem C

Ninetail doesn't love playing card game. But XGN forced her to do so because she has the ability to turn anything into one another. So she did!

Now Ninetail is playing card games with Doragon. Ninetail has N cards, the i-th card has an attack point of $A_i$. Doragon has M cards, the i-th card has an defense point of $B_i$

The turn goes as follows:

Ninetail wants to end this stupid game quickly know what's the maximum possibility she could win if only she plays optimally.

Input

The first line contains integers N,M

The next line contains N integers, the array A

The next line contains M integers, the array B

Output

Let the answer be P.

Print $P\times M!$ module $10^9+7$

Example

[Input]
5 3
1 2 3 4 5
2 3 5
[Output]
2
[Explain]
the best C={3,4,5}:
{3,4,5} vs {2,3,5} win
{3,4,5} vs {2,5,3} NOT win because 4<5
{3,4,5} vs {3,2,5} win
{3,4,5} vs {3,5,2} NOT win
{3,4,5} vs {5,3,2} NOT win
{3,4,5} vs {5,2,3} NOT win

Subtask

$1\leq M\leq N\leq 2*10^5,1\leq A_i,B_i\leq 10^9$

M in all testcases(N will be at most 3*M):

Testcase #M
11
22
33
45
510
620
740
8100
9200
10500
111000
122000
135000
1410000
1520000
1650000
17100000
18100000
19200000
20200000

Submit