output_description: Print the maximum possible sum of the deliciousness of the eaten apples.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      X Y A B C
      p_1 p_2 ... p_A
      q_1 q_2 ... q_B
      r_1 r_2 ... r_C
attempt: #!/usr/bin/ python3.8
  import sys
  
  read = sys.stdin.buffer.read
  readline = sys.stdin.buffer.readline
  readlines = sys.stdin.buffer.readlines
  
  N = int(readline())
  m = map(int, read().split())
  AB = zip(m, m)
  
  MOD = 10**9 + 7
  
  graph = [[] for _ in range(N + 1)]
  for a, b in AB:
      graph[a].append(b)
      graph[b].append(a)
  
  root = 1
  parent = [0] * (N + 1)
  order = []
  stack = [root]
  while stack:
      x = stack.pop()
      order.append(x)
      for y in graph[x]:
          if y == parent[x]:
              continue
          parent[y] = x
          stack.append(y)
  
  fact = [1] * (N + 10)
  for n in range(1, N + 10):
      fact[n] = n * fact[n - 1] % MOD
  fact_inv = [1] * (N + 10)
  fact_inv[-1] = pow(fact[-1], MOD - 2, MOD)
  for n in range(N + 9, 0, -1):
      fact_inv[n - 1] = fact_inv[n] * n % MOD
  
  size_d = [0] * (N + 1)
  dp_d = [1] * (N + 1)
  
  for v in order[::-1]:
      dp_d[v] *= fact[size_d[v]]
      dp_d[v] %= MOD
      p = parent[v]
      s = size_d[v] + 1
      size_d[p] += s
      dp_d[p] *= fact_inv[s] * dp_d[v]
      dp_d[p] %= MOD
  
  size_u = [N - 2 - x for x in size_d]
  dp_u = [1] * (N + 1)
  
  for v in order[1:]:
      p = parent[v]
      x = dp_d[p]
      x *= dp_u[p]
      x *= fact_inv[size_d[p]]
      x *= fact[size_d[v] + 1]
      x *= pow(dp_d[v], MOD - 2, MOD)
      x *= fact[size_u[v]]
      x *= fact_inv[size_u[p] + 1]
      dp_u[v] = x % MOD
  
  for xd, xu, sd, su in zip(dp_d[1:], dp_u[1:], size_d[1:], size_u[1:]):
      su += 1
      x = xd * xu * fact[sd + su] * fact_inv[sd] * fact_inv[su] % MOD
      print(x)
  
problem_description: Statement
  
  You are going to eat X red apples and Y green apples.  
  You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of
  deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness
  r_1,r_2, \dots, r_C.  
  Before eating a colorless apple, you can paint it red or green, and it will
  count as a red or green apple, respectively.  
  From the apples above, you will choose the apples to eat while making the sum
  of the deliciousness of the eaten apples as large as possible.  
  Find the maximum possible sum of the deliciousness of the eaten apples that
  can be achieved when optimally coloring zero or more colorless apples.
samples: [{"input": "1 2 2 2 1\n    2 4\n    5 1\n    3", "output": "12\n    \n\nThe maximum possible sum of the deliciousness of the eaten apples can be\nachieved as follows:\n\n  * Eat the 2-nd red apple.\n  * Eat the 1-st green apple.\n  * Paint the 1-st colorless apple green and eat it.\n\n* * *"}, {"input": "2 2 2 2 2\n    8 6\n    9 1\n    2 1", "output": "25\n    \n\n* * *"}, {"input": "2 2 4 4 4\n    11 12 13 14\n    21 22 23 24\n    1 2 3 4", "output": "74"}]