Cartesian Conquest

A rectangle N by M must be tiled by rectangles with side ratio 2:1, added one at a time so the union stays a rectangle; find the min and max tile counts.

Hard8MathNumber theoryGreedyImplementationNo attempts yetTime limit2sMemory limit512 MB

Problem

Long ago, in the land of Cartesia, the Rectangle Empire ruled. The empire was large and prosperous, and it grew by conquering its neighbors again and again. Most customs of that civilization are no longer understood, but the way it divided its land is known.

The territory of the empire was split into districts, and the districts always met three conditions.

  1. Every piece of land the empire controls belongs to exactly one district.
  2. On a map, the boundary of each district is a rectangle whose longer side is exactly twice its shorter side.
  3. Both side lengths of a district are integers when measured in Ξ, the unit of length used in the Rectangle Empire.

When the empire was founded it consisted of a single district. After that it gained districts by conquest, and every time it took a new region it turned exactly that land into one new district. No two conquests happened at the same time. Adding a district was the only way the borders ever changed, and once a district existed it was never split, reshaped, or merged with another one.

The custom the empire cared about most is that the whole territory had to be a rectangle after every conquest. Unlike a single district, the whole territory does not need side lengths in the ratio 2:12:1.

Archaeologists found that at one moment the empire measured N×MN \times M in Ξ. Cartesia is an infinite plane, so these numbers can be very large. Over all the ways the empire could have been founded and expanded, find the minimum and the maximum possible number of districts at that moment.

Input

The first and only line contains two integers NN and MM (1N,M1081 \le N, M \le 10^8).

Output

Print the minimum number of districts and the maximum number of districts on one line, separated by a space. If no history of founding and conquest produces an N×MN \times M empire, print -1 -1 instead.

Note

The picture below shows how the minimum of 5 districts and the maximum of 8 districts are reached for a 10×610 \times 6 empire. The labels #1, #2, #3, and so on give the order in which the districts were added, and the size of each district is written in brackets as (k×2k)(k \times 2k) or (2k×k)(2k \times k).