import std.conv, std.stdio, std.string; import std.algorithm, std.array, std.bigint, std.container, std.math, std.range, std.regex, std.typecons; import core.bitop; class EOFException : Throwable { this() { super("EOF"); } } string[] tokens; string readToken() { for (; tokens.empty; ) { if (stdin.eof) throw new EOFException; tokens = readln.split; } auto token = tokens[0]; tokens.popFront; return token; } int readInt() { return readToken().to!int; } long readLong() { return readToken().to!long; } real readReal() { return readToken().to!real; } void chmin(T)(ref T t, in T f) { if (t > f) t = f; } void chmax(T)(ref T t, in T f) { if (t < f) t = f; } int binarySearch(T)(in T[] as, in bool delegate(T) test) { int low = -1, upp = cast(int)(as.length); for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp; } int lowerBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a < val)); } int upperBound(T)(in T[] as, in T val) { return as.binarySearch((T a) => (a <= val)); } int N; real[] P; int[][] A; void main() { try { for (; ; ) { N = readInt(); P = new real[2]; foreach (h; 0 .. 2) { P[h] = readReal(); } A = new int[][](2, N); foreach (h; 0 .. 2) { foreach (i; 0 .. N) { A[h][i] = readInt(); } A[h].sort; } auto prob = new real[][][](2, N, N); auto dp = new real[][](2, 1 << N); foreach (h; 0 .. 2) { foreach (k; 0 .. N) { prob[h][k][] = 0.0; } dp[h][] = 0.0; dp[h][(1 << N) - 1] = 1.0; foreach_reverse (s; 1 .. 1 << N) { const pop = popcnt(s); const k = N - pop; const iMin = bsf(s); if (pop == 1) { prob[h][k][iMin] += dp[h][s] * 1.0; dp[h][s ^ 1 << iMin] += dp[h][s] * 1.0; } else { prob[h][k][iMin] += dp[h][s] * P[h]; dp[h][s ^ 1 << iMin] += dp[h][s] * P[h]; foreach (i; iMin + 1 .. N) { if ((s >> i) & 1) { prob[h][k][i] += dp[h][s] * ((1.0 - P[h]) / (pop - 1)); dp[h][s ^ 1 << i] += dp[h][s] * ((1.0 - P[h]) / (pop - 1)); } } } } } debug { foreach (h; 0 .. 2) { writefln("h = %s", h); foreach (k; 0 .. N) { writefln(" prob[%s][%s] = %s", k, h, prob[h][k]); } } } real ans = 0.0; foreach (k; 0 .. N) { foreach (i0; 0 .. N) foreach (i1; 0 .. N) { if (A[0][i0] > A[1][i1]) { ans += prob[0][k][i0] * prob[1][k][i1] * (A[0][i0] + A[1][i1]); } } } writefln("%.10f", ans); } } catch (EOFException e) { } }