The first line contains N.
The second line contains N space-separated integers s1,s2,…,sN.
The third line contains N space-separated integers t1,t2,…,tN.
The number of maximal matchings mod 109+7.
Here is a list of all nine maximal matchings. An ordered pair (i,j) means that cow i is assigned to barn j.
(1, 1), (2, 2), (3, 4) (1, 1), (2, 3), (3, 4) (1, 1), (2, 4) (1, 2), (2, 3), (3, 4) (1, 2), (2, 4) (1, 3), (2, 2), (3, 4) (1, 3), (2, 4) (1, 4), (2, 2) (1, 4), (2, 3)
In test cases 2-3, N≤8.
In test cases 4-12, N≤50.
In test cases 13-20, there are no additional constraints.
Problem credits: Nick Wu