import bisect,collections,copy,itertools,math,string import sys def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) def main(): n = I() a = LI() b = LI() a_per = list(itertools.permutations(a)) b_per = list(itertools.permutations(b)) all_game = math.factorial(n)**2 cnt_game = 0 for acards in a_per: for bcards in b_per: acnt = 0 for acard, bcard in zip(acards, bcards): if acard>bcard: acnt+=1 bcnt = n-acnt if acnt>bcnt: cnt_game+=1 ans = cnt_game/all_game print(ans) main()