P27051 [AtCoder] school competition 1
NOI
题目描述

Problem Description

There are two elementary schools on Paken Island, anmichi School and sanada School, and the people on the island attend one of these schools and practice competitive programming daily. These people participate in a weekly contest hosted by PatCoder, and each person has a rating value that represents their ability. The rating of the $i$-th student at anmichi School is $A_i$, and the rating of the $j$-th student at sanada School is $B_j$.

One day, it was decided that the traditional interschool competition would be held again this year. In this competition, two students from each school will be selected to form teams. To minimize the difference in strength between the selected students, define, the organizer of the competition, told each school to select two students such that:

  • Let the ratings of the two selected students from anmichi School be $P$ and $Q$ in ascending order, and the ratings of the two selected students from sanada School be $R$ and $S$ in ascending order. Then, $R < P < Q < S$.

Define is curious about how many ways there are to select these four students that satisfy the condition. For define, calculate the number of ways to select these four students modulo $10^9+7$. Note that you are not calculating the number of different rating combinations.

Input Format

The input is given from the standard input in the following format:

$ N $ $ M $
$ A_1 $ $ A_2 $ $\ldots$ $ A_{N-1} $ $ A_N $
$ B_1 $ $ B_2 $ $\ldots$ $ B_{M-1} $ $ B_M $

Output Format

Output the number of ways to select the four students modulo $10^9+7$ in one line.

Sample Input and Output

Sample Input #1

4 4
40 60 20 10
25 30 80 50

Sample Output #1

2

Sample Input #2

None

Sample Output #2

4

Sample Input #3

None

Sample Output #3

0

Notes/Hints

Constraints

  • All inputs are integers.
  • $2 \leq N, M \leq 2 \times 10^5$
  • $1 \leq A_i, B_j \leq 10^9$ $(1 \leq i \leq N, 1 \leq j \leq M)$
  • All $A_i$ are distinct.
  • All $B_j$ are distinct.
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
4 4 40 60 20 10 25 30 80 50
样例输出
2