R=range J=lambda:map(int,input().split()) O=print H,W=J() A=sorted(J()) B=sorted(J()) P=10**9+7 i=H-1 a=sum(A) for b in B[::-1]: while i>0and b-1and A[i]==b:i-=1 else:a+=b O(a%P) i=a=s=0 for b in B: while i