import java.util.*; public class Main { static int[] aList; static int[] bList; static int count; static int n; public static void main(String[] args) { Scanner sc = new Scanner(System.in); n = sc.nextInt(); aList = new int[n]; bList = new int[n]; for (int i = 0; i < n; i++) { aList[i] = sc.nextInt(); } for (int i = 0; i < n; i++) { bList[i] = sc.nextInt(); } calc(0, 0); System.out.println(count / (kaijo(n) * kaijo(n))); } static double kaijo(int x) { if (x == 1) { return 1; } else { return x * kaijo(x - 1); } } static void calc(int idx, int win) { if (idx == n) { if (win * 2 > n) { count++; } return; } for (int i = 0; i < n; i++) { if (aList[i] == 0) { continue; } int x = aList[i]; aList[i] = 0; for (int j = 0; j < n; j++) { if (bList[j] == 0) { continue; } int y = bList[j]; bList[j] = 0; int tmp = win; if (x > y) { tmp++; } calc(idx + 1, tmp); bList[j] = y; } aList[i] = x; } } }