Under construction

Still being built. Things may change

Greatest Common Divisor and Least Common Multiple

Interview

Time limit1sMemory limit128 MB

Summary
Given the gcd and lcm of two unknown natural numbers, find the pair with the smallest sum satisfying both conditions.
Level

Easy3 of 10

Topics
Number theory, Math, Brute force
Solved
No attempts yet

Problem

You are given the greatest common divisor and the least common multiple of two natural numbers. Find two natural numbers whose greatest common divisor and least common multiple are exactly those two given values.

There can be several valid pairs. For instance, if the greatest common divisor is 6 and the least common multiple is 180, possible pairs include (12, 90), (30, 36), (18, 60), and (6, 180). Among all valid pairs, choose the one with the smallest sum.

Write a program that finds the two natural numbers.

Input

The first line contains two natural numbers G and L separated by a space. G is the greatest common divisor of the two numbers to find, and L is their least common multiple. Both numbers are between 2 and 100,000,000, inclusive.

Output

Print the two natural numbers that satisfy the condition, in increasing order, separated by a space. If there are multiple valid pairs, print the pair whose sum is as small as possible.

Examples2

  1. Example 1

    Input
    6 180
    
    Expected output
    30 36
    
  2. Example 2

    Input
    2 86486400
    
    Expected output
    11648 14850