local ior = io.input() local n = ior:read("*n") local a, b = {}, {} for i = 1, n do a[i] = ior:read("*n") end for i = 1, n do b[i] = ior:read("*n") end local tot = 1 for i = 2, n do tot = tot * i end local wincnt = 0 local function getcard(idx, tbl) local ret = {} local box = {} for i = 1, n do box[i] = true end for i = n, 1, -1 do local dv = 1 for k = 1, i - 1 do dv = dv * k end local tgt = math.floor(idx / dv) local i_tgt = 0 for j = 1, n do if(box[j]) then if(tgt == i_tgt) then table.insert(ret, tbl[j]) box[j] = false break else i_tgt = i_tgt + 1 end end end idx = idx % dv end return ret end for i_match = 0, tot * tot - 1 do local i_a = i_match % tot local i_b = math.floor(i_match / tot) ac = getcard(i_a, a) bc = getcard(i_b, b) local score = 0 for i = 1, n do if(bc[i] < ac[i]) then score = score + 1 elseif(ac[i] < bc[i]) then score = score - 1 end end if(0 < score) then wincnt = wincnt + 1 end end print(string.format("%.8f", wincnt / (tot * tot)))