def g;gets.split.map(&:to_i)end n,=g a,b=g,g t=[*a.permutation].product([*b.permutation]) p 1.0*t.count{|i,j|i.zip(j).count{|k,l|k>l}*2>n}/t.size