Klaus

We are creating an arrangement of  fake Christmas trees, equally-spaced along a line, for the
backdrop of a play.

Each of the fake trees is made out of a vertical trunk and one or more identical triangular pieces
of foam designed to be attached to that particular trunk. The pieces for tree
 all have exactly the same shape of an isosceles triangle with base width
equal to double the height ( centimetres).

A tree trunk can have triangles attached at predefined attachment points
defined in terms of the elevation from the base of the tree. To make the trees
look as full of life as possible, in their foamy way, we want the sum of the
areas of the pieces attached on the trees to be as large as possible.

However, the set of pieces we can actually install is limited because we do not
want any of the triangles to overlap each other except for touching at the
perimeter.

Find a subset of pieces to use with the maximum possible area, while still
having none of the pieces on any of the trees overlap.

figure[!h]
sample1.pdf

sample2.pdf
Tree arrangements illustrating samples 1 and 2.
figure

Find the maximum sum of areas of triangles that we can install.

Input
    itemize
        One line containing the integer distance between trees  and , and between  and  in centimetres,  (),
        Three descriptions of trees , , and :
        itemize
          One line containing the number of triangle positions  and triangle size  of the -th tree.
                (; ).
          One line containing the  possible integer triangle heights in centimetres,  ().
        itemize
    itemize

Output
    Output the maximum possible combined area of triangular pieces on the trees.
