#1632 Four Gate Push

15  10 s   256 MB  


 You are working hard on your Protoss builds in StarCraft II, especially the 4 Gate Push. You've come upon a tough problem, however, which is how to determine the distribution of zealots, stalkers, and sentries to maximize your army strength. Recall (although you should already know!) that zealots cost 100 minerals and no gas, stalkers cost 125 minerals and 50 gas, and sentries cost 50 minerals and 100 gas. Given your current economy and how much each unit increases your army strength, determine the maximum army strength you can obtain.


 The input consists of multiple test cases, one on each line. Each test case has 5 integers M (0 ≤  M ≤ 50,000), the amount of minerals you have, G (0 ≤ G ≤ 50,000), the amount of gas you have, Z (0 ≤ Z  ≤ 1,000), the strength of a zealot in your army, S (0 ≤ S  ≤ 1,000), the strength of a stalker in your army, and E (0 ≤ E ≤ 1,000), the strength of a sentry in your army. Input is followed by a single line with M = G = Z = S = E = 0, which should not be processed. For example:


 For each case, output a single line containing the maximum army strength you can obtain.

Sample Input

Sample Output

500 400 10 20 15
0 0 0 0 0