n = gets.to_i a = gets.split(" ").map &:to_i b = gets.split(" ").map &:to_i count = 0 win = 0 a.permutation(n).each do |_a| b.permutation(n).each do |_b| count += 1 win += 1 if [*0...n].inject(0){|s, i| s += (_a[i] <=> _b[i])} > 0 end end p 1.0 * win / count