#Lutece1273. God Qing's circuital law
God Qing's circuital law
Migrated from Lutece 1273 God Qing's circuital law
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
As we all know,God Qing is a very powerful ACMer. She very like junior sister apprentice,but in UESTC-ACM team,there is no junior sister apprentice,we can use a mathematical formula to express it.
But God Qing is a life winner , she has many beautiful girls,every girl has its BeautifulValue V ,and he want to take the most beautiful girl among all girls. For every girl,if God Qing chooses her,she can get a value called Life-Winner Point. We can use a mathematical formula to express it.
When other people who come from UESTC-ACM team(such as Liao772002,Final-Pan,Final-Zhu and so on) know God Qing want to choose the most beautiful girl,they can't stand it! ,They also want a girl,for every person,he/she has its own HandsomeValue P. But God Qing wants to make her Life-Winner Point most,so she wants you to tell her there are how many ways can GodQing get the most Life-Winner Point.
In general. Thre are competitors come from UESTC-ACM team(God Qing's ID is always ) and Girls, for every competitor,he/she has a HandsomeValue , for every girl , she has a BeatuifulValue ,every competitor can only choose a girl,and every girl can be only chose once. you should calculate there are how many ways that make GodQing get the most Life-Winner Point. (God Qing’s Life-Winner Point strictly greater than any other competitors).
Because the answer can be very large,you only need to print the answer modulo .
Input
Line 1: an integet (the number of competitors and girls).
Line 2: numbers (the HandsomeValue of every competitor)
Line 3: numbers (the BeautifulValue of every girl).
, , .
Output
the number of ways that GodQing can get the most Life-Winner Point.
Samples
Note
Valid assignment #1: (5,40), (8,19), (4,25), (8,20).
Valid assignment #2: (5,40), (8,20), (4,25), (8,19).
In assignment #1, the Life-Winner Point of God Qing is 5 x 40 = 200. The other three units have Life-Winner Point 8 x 19 = 152, 4 x 25 = 100, and 8 x 20 = 160. This is a valid assignment because the number 200 is strictly greater than each of the numbers 152, 100, and 160.
Resources
第七届ACM趣味程序设计竞赛第四场(正式赛)