#GYM104618G. Ice Cream Gambling

Ice Cream Gambling

Description

You and your friend Greg are running an ice cream stand at a local fair.

Now, you know chocolate-mint-flavored ice cream is the best flavor. Since it is the best flavor, there are $N\ (1\leq N\leq 10^5)$ customers lined up outside your stand who only want chocolate-mint ice cream, and the $i$-th customer will offer you $r_i\ (0\leq r_i\leq 10^9)$ dollars for a single cone of chocolate-mint ice cream.

While on your break, Greg found $M\ (1\leq M\leq 10^5)$ mystery-flavored ice cream cones on the ground. Greg, being greedy, decides to pick up all the ice cream cones, and offers to sell you the $i$-th ice cream cone for $c_i\ (0\leq c_i\leq 10^9)$ dollars.

Now, you also have a friend Alex, who absolutely loves gambling, and will bet any amount that any ice cream cone that Greg picked up is chocolate-mint or not.

However, you have just run out of chocolate-mint ice cream, and so instead sell your customers a mystery-flavored ice cream cone: if the mystery flavor turns out to be chocolate-mint, then you profit $r_i\ (0\leq r_i\leq 10^9)$ dollars, otherwise, you profit $0$.

Being the talented owner you are, you want to find the maximum profit you can guarantee and the number of ways you can maximize both the number of customers and profit at the same time.

The first line contains two integers, $N$ and $M$.

The second line will contain $N$ integers, where the $i$-th integer is $r_i\ (1\leq r_i\leq 10^9)$, the amount that you will profit if you're able to sell a cone to the $i$-th customer.

The third line will contain $M$ integers, where the $i$-th integer is $c_i\ (0\leq c_i\leq 10^9)$, the cost that you can buy the $i$-th ice cream cone for.

Print the following separated by a space:

  • What is the maximum profit you can guarantee? Answers within $10^{-9}$ of the judge answer will be counted as correct.
  • How many ways can you maximize the number of customers and guaranteed profit at the same time? Print this number mod $10^9+7$. Two ways are considered different if some customer gets a different cone. There is one way to make zero profit for zero customers (by doing nothing).

Input

The first line contains two integers, $N$ and $M$.

The second line will contain $N$ integers, where the $i$-th integer is $r_i\ (1\leq r_i\leq 10^9)$, the amount that you will profit if you're able to sell a cone to the $i$-th customer.

The third line will contain $M$ integers, where the $i$-th integer is $c_i\ (0\leq c_i\leq 10^9)$, the cost that you can buy the $i$-th ice cream cone for.

Output

Print the following separated by a space:

  • What is the maximum profit you can guarantee? Answers within $10^{-9}$ of the judge answer will be counted as correct.
  • How many ways can you maximize the number of customers and guaranteed profit at the same time? Print this number mod $10^9+7$. Two ways are considered different if some customer gets a different cone. There is one way to make zero profit for zero customers (by doing nothing).
2 2
100 100
20 20
3 3
1 2 3
0 0 0
2 1
100 100
1
60 2
3 6
49 2