Vacuum Tubes

No attempts yetTime limit1sMemory limit256 MB

Problem

An X-ray lab keeps evacuated tubes between the source and the sample, and between the sample and the detector, so that the air does not absorb the X-rays. The sample and the detector sit at different places in different experiments, so tubes of several lengths are kept ready. A tube has a vacuum window at one end only, so two tubes are fixed together into a pair. One pair goes between the source and the sample, the other pair goes between the sample and the detector. Longer tubes leave less air, but the space between the source and the sample is L1L_1 mm and the space between the sample and the detector is L2L_2 mm.

You are given the tube lengths and the two distances L1L_1 and L2L_2. Choose four tubes so that the sum of the first two lengths is at most L1L_1, the sum of the last two lengths is at most L2L_2, and the total length of the four tubes is as large as possible. Each tube can be used at most once.

Input

The first line contains three integers L1L_1, L2L_2 and NN separated by spaces. L1L_1 and L2L_2 are the two distances described above, in mm (1L1,L2100001 \le L_1, L_2 \le 10000). NN is the number of available tubes (4N20004 \le N \le 2000).

Each of the next NN lines contains the length of one tube in mm, an integer between 1 and 10000.

Output

Print the largest possible total length of the four chosen tubes on one line. If no two disjoint pairs fit into the two spaces, print Impossible instead.