Second Gear Bessie's beaux-vine friend, Hugh, is in the market for a new bicycle. Like his current one, it will have 2 distinct gears (sprockets) in the front and 5 distinct gears in the rear, for a total of 10 possible speeds. Hugh has F (2 <= F <= 6) distinct gear sizes he can choose for the front gears and R (5 <= R <= 15) distinct gear sizes he can choose for the rear gears. At any given setting, the gear ratio is defined as the number of teeth on the front gear divided by the number of teeth on the rear gear. Hugh needs a set of gears such that the largest gear ratio will be at least three times the smallest gear ratio. Hugh's front gears range in size from 25..80; his rear gears range in size from 5..40. When Hugh first moved to the country, he built a Cowcycle with gears that minimized the variance of the set of differences between successive gear ratios. Since then he has reasoned that this doesn't actually give the smoothest ride. Instead of minimizing the variance, he now wants to minimize the maximum of the set of multiplicative factors between successive gear ratios. For example, suppose Hugh has two front gears of size 39 and 40, and five rear gears of size 12, 13, 14, 15, and 16. First, calculate all the possible ratios: 39/12 = 3.25000000000000000000 39/13 = 3.00000000000000000000 39/14 = 2.78571428571428571428 39/15 = 2.60000000000000000000 39/16 = 2.43750000000000000000 40/12 = 3.33333333333333333333 40/13 = 3.07692307692307692307 40/14 = 2.85714285714285714285 40/15 = 2.66666666666666666666 40/16 = 2.50000000000000000000 Then, sort them: 39/16 = 2.43750000000000000000 40/16 = 2.50000000000000000000 39/15 = 2.60000000000000000000 40/15 = 2.66666666666666666666 39/14 = 2.78571428571428571428 40/14 = 2.85714285714285714285 39/13 = 3.00000000000000000000 40/13 = 3.07692307692307692307 39/12 = 3.25000000000000000000 40/12 = 3.33333333333333333333 Then, compute the factors between successive gear ratios: 2.50000000000000000000 / 2.43750000000000000000 = 1.025641025641025641026 2.60000000000000000000 / 2.50000000000000000000 = 1.040000000000000000000 2.66666666666666666666 / 2.60000000000000000000 = 1.025641025641025641026 2.78571428571428571428 / 2.66666666666666666666 = 1.044642857142857142857 2.85714285714285714285 / 2.78571428571428571428 = 1.025641025641025641026 3.00000000000000000000 / 2.85714285714285714285 = 1.050000000000000000000 3.07692307692307692307 / 3.00000000000000000000 = 1.025641025641025641026 3.25000000000000000000 / 3.07692307692307692307 = 1.056250000000000000000 3.33333333333333333333 / 3.25000000000000000000 = 1.025641025641025641026 The maximum factor is 1.05625. (Unfortunately, this is not a valid gear set, because the largest gear ratio (3.3333) is not at least three times the smallest gear ratio (2.4375).) Of the valid gear sets, find the one that minimizes the maximum of the successive gear ratio factors. PROBLEM NAME: gear INPUT FORMAT: * Line 1: Two space-separated integers: F and R * Line 2: F space-separated integers: the possible gear sizes that Hugh can use for the front gear. * Line 3: R space-separated integers: the possible gear sizes that Hugh can use for the rear gear. SAMPLE INPUT: 2 15 39 40 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 INPUT DETAILS: Hugh has only two possible gears for the front, of size 39 and 40. For the rear, Hugh can choose any gears with sizes between 5 and 19. OUTPUT FORMAT: * Line 1: 7 space-separated integers: the gear set that minimizes the maximum successive gear ratio factor. Print the front gears in increasing order; print the rear gears in increasing order. If multiple optimal answers exist, print the answer with the smallest front gear set (smallest first gear, or smallest second gear if first gears match, etc.). Likewise, if all first gears match, print the answer with the smallest rear gear set (similar rules to the front gear set). SAMPLE OUTPUT: 39 40 5 6 8 11 15 OUTPUT DETAILS: This gear set has a maximum gear ratio factor of 1.340625.