import bisect import os from collections import Counter, deque from fractions import gcd from functools import lru_cache from functools import reduce import functools import heapq import itertools import math import numpy as np import re import sys if os.getenv("LOCAL"): sys.stdin = open("_in.txt", "r") sys.setrecursionlimit(2147483647) INF = float("inf") N, PA, PB = sys.stdin.readline().rstrip().split() A = list(map(int, sys.stdin.readline().split())) B = list(map(int, sys.stdin.readline().split())) N = int(N) PA = float(PA) PB = float(PB) A.sort() B.sort() def probabilities(cards, first_p): """ :param list of int cards: :param float first_p: 最初のカードを選ぶ確率 :return: """ cards.sort() # ret[i][j]: i 試合目で cards[j] を出す確率 ret = np.zeros((N, N)) # dp[bit]: 持ってるカードが bit になる確率 # 左から i 番目のビットが立ってたら cards[i] が手持ちにある # dp する過程で ret を計算する dp = np.zeros(1 << N) # 初期 dp[(1 << N) - 1] = 1 states = {(1 << N) - 1} for step in range(N): nexts = set() for st in states: first = step < N - 1 for b in range(N): mask = 1 << b next_st = st ^ mask if next_st > st: continue nexts.add(next_st) if first: p = dp[st] * first_p first = False elif step == N - 1: p = dp[st] else: p = dp[st] * (1 - first_p) / (N - step - 1) dp[next_st] += p ret[step][b] += p states = nexts return ret np.set_printoptions(suppress=True) AP = probabilities(cards=A, first_p=PA) BP = probabilities(cards=B, first_p=PB) ans = 0 for step in range(N): for a in range(N): for b in range(N): if A[a] > B[b]: ans += (A[a] + B[b]) * AP[step][a] * BP[step][b] print(ans)