Under construction

Still being built. Things may change

Matching Mentors

Time limit1sMemory limit1024 MB

Summary
Count the ways to match students with mentors, each student and mentor used at most once, that maximize the minimum final skill across all students.
Level

Medium7 of 10

Topics
Binary search, Greedy, Sorting, Combinatorics
Solved
No attempts yet

Problem

There are NN students and MM mentors. You want to raise the skills of the students by matching them with mentors.

Student ii has skill AiA_i, and mentor jj has leadership BjB_j. You can match at most one mentor to each student, and each mentor can guide at most one student. A student may also be left without a mentor. When a mentor is matched to a student, that student's skill increases by the mentor's leadership.

Count the number of mentor matching methods that maximize the minimum skill among all students.

Input

The first line contains the number of students NN and the number of mentors MM, separated by a space. (1≤N,M≤200 000)(1 \leq N, M \leq 200\,000)

The second line contains the skills of the students AA, separated by spaces. (1≤Ai≤109)(1 \leq A_i \leq 10^9)

The third line contains the leadership of the mentors BB, separated by spaces. (1≤Bj≤109)(1 \leq B_j \leq 10^9)

Output

Print the number of mentor matching methods that maximize the minimum skill of all students, modulo 109+710^9 + 7.

Examples2

  1. Example 1

    Input
    2 3
    3 5
    1 3 2
    
    Expected output
    2
    
  2. Example 2

    Input
    4 2
    2 5 3 3
    5 10
    
    Expected output
    8