from itertools import permutations from math import factorial N = int(input()) A = list(map(int,input().split())) B = list(map(int,input().split())) total = factorial(N)**2 win = 0 for Pattern_A in permutations(A): for Pattern_B in permutations(B): win_cnt = 0 for a,b in zip(Pattern_A, Pattern_B): if a>b: win_cnt += 1 if win_cnt > N//2: win+=1 print(win/total)