bholu-the-pandit-1

Bholu the Pandit on this New Year wanted to divide his Cuboidal Packaging block into cubes.
But he loves uniformity so he asks you to divide it such a way that all the cubes are of same size and volume of individual cube is as large as possible.

Note: He will utilize whole volume i.e volume of cuboid before dividing is same as sum of volume of all the cubes.

Input
The first input line contains an integer T, the number of testcases. 
Each testcase consist of single line which consist of 3 space separated integers a, b & c representing length, breadth and height of the Cuboidal block.

Output
For each testcase you need to output 2 space separated integers, the length of side of the cube and the number of cubes which could be formed out of this cuboidal packaging block.
As the number of cubes which could be made could be a large number so just output the answer modulus 10^9+7 (1000000007).

Constraints
1 ≤ T ≤ 1000
1 ≤ a,b,c ≤ 10^9

SAMPLE INPUT
2
2 4 6
1 2 3

SAMPLE OUTPUT
2 6
1 6

Explanation

In the 1st testcase a=2, b=4 & c=6.
So length of the side of the cube would be 2 and the number of cubes which would be formed would be 6.
In the 2nd testcase a=1, b=2 & c=3.
So length of the side of the cube would be 1 and the number of cubes which would be formed would be 6.

Source: hackerearth | Difficulty: EASY
Tags: Mathematics


Solutions:
t = int(input())
def gcd(a,b):
	if(b==0):
		return a
	else:
		return gcd(b,a%b)
for i in range(t):
	l = [int(j) for j in input().split()]
	k = gcd(gcd(l[0],l[1]),l[2])
	n = ((l[0]*l[1]*l[2])/(k**3))%1000000007
	print(str(k)+" "+str(n))


from fractions import gcd
t=int(eval(input()))
while t>0:
	l,b,h=list(map(int,input().split()))
	a=gcd(gcd(l,b),h)
	ans=((l*b*h)/(a*a*a))%1000000007
	print(a, ans)
	t-=1


import sys
def gcd(a,b):
	if(a%b==0):
		return b
	else:
		return gcd(b,a%b)
def cal():
	t=input()
	t=int(t)
	while t>0:
		r=0
		o=0
		f=0
		r=int(r)
		o=int(o)
		f=int(f)
		a,b,c=sys.stdin.readline().split(' ')
		a=int(a)
		b=int(b)
		c=int(c)
		r=gcd(a,gcd(b,c))
		o=r*r*r
		f=a*b*c
		print((str(r)+" "+str((f/o)%(1000000007))))
		t=t-1
cal()
		


from sys import stdin
from fractions import gcd
from functools import reduce
for i in range(int(stdin.readline())):
	a=list(map(int,stdin.readline().split()))
	b=reduce(gcd,a)
	print(b, ((a[0]*a[1]*a[2])/b**3)%1000000007)
	


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
from fractions import gcd
for i in range(eval(input())):
	a,b,c=list(map(int,input().split()))
	m=a*b*c
	ans=gcd(int(a),gcd(int(b),int(c)))
	fin=((int(m))/(ans*ans*ans))%1000000007
	print(ans,fin)



from fractions import gcd
test = int(eval(input()))
while test:
	test=test-1
	sub = list(map(int,input().split()))
	size = gcd(sub[0],gcd(sub[1],sub[2]))
	total = ((sub[0]*sub[1]*sub[2])/(size*size*size))%1000000007
	print(size,total)
	


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
import math
def hcf(x, y):
	while(y):
		 x, y = y, x % y
 
	return x
for _ in range(eval(input())):
	a,b,c =  list(map(int,input().split()))
	l = hcf(a,b)
	l = hcf(l,c)
	vol = l*l*l
	vol1 = a*b*c
	print(l, (vol1//vol)%(10**9+7))



from fractions import gcd
t=int(input())
while t:
	t-=1
	l,b,h=list(map(int,input().split()))
	a=gcd(l,gcd(b,h))
	n=(l/a)*(b/a)*(h/a)
	n=n%(1000000007)
	print(a,n)


def gcd(a, b):
	if b == 0: return a
	return gcd(b, a % b)
	
for i in range(int(input())):
	lst = list(map(int,input().split()))
	volCuboid = lst[0] * lst[1] * lst[2]
	edge = gcd(gcd(lst[0],lst[1]),lst[2])
	print(edge%1000000007,(volCuboid/edge**3)%1000000007)



from fractions import gcd
t=0
t=int(input())
for i in range(t):
	a,b,c=list(map(int,input().split()))
	x=gcd(a,gcd(b,c))
	y=a*b*c
	y/=(x*x*x)
	y%=1000000007
	print(x, y)
	


from fractions import gcd
t=eval(input())
while t:
	str=input()
	a,b,c=str.split()
	a=int(a)
	b=int(b)
	c=int(c)
	x=gcd(a,b)
	y=gcd(x,c)
	print(y,((a*b*c)/(y*y*y))%1000000007)
	t-=1


from fractions import gcd
mod = 1000000007
for T in range(eval(input())):
	a,b,c = list(map(int,input().split()))
	side = gcd(a, gcd(b,c))
	number = ( (a*b*c)/ side**3 ) % mod
	print(side, number)


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a%b)

def main():
	test_cases = int(input())
	for _ in range(test_cases):
		L, B, H = input().split()
		l, b, h = int(L), int(B), int(H)
		Volume = l*b*h
		possible_dim = gcd(l,gcd(b,h))
		number = Volume/(possible_dim**3)
		
		print(int(possible_dim%1000000007), int(number%1000000007))
	
	return 0
	
if __name__ == "__main__":
	main()


import fractions
t=input()
t=int(t)
while t>0:
	t=t-1
	a,b,c=list(map(int,input().split()))
	a=int(a)
	b=int(b)
	c=int(c)
	minn=fractions.gcd(a,fractions.gcd(b,c))
	if minn!=1:
		ans=(a*b*c)/(minn*minn*minn)
	else:
		ans=a*b*c
	ans=ans%1000000007
	print(minn,ans)


from fractions import gcd
mod = 1000000007
t = int(input())
while t > 0:
	a, b, c = list(map(int, input().split()))
	side = gcd(a, gcd(b, c))
	ans = ((a*b*c)/(side**3))
	print(side, ans%mod)
	t -= 1


from fractions import gcd as g
for _ in range(eval(input())):
	a,b,c=list(map(int,input().split()))
	m=10**9+7
	d=g(a,g(b,c))
	print(d%m,((a*b*c)/(d*d*d))%m)
	


def gcd(a,b):
	if(b==0):
		return a
	else:
		return gcd(b,a%b)

t = eval(input())
for i in range(t):
	s = input().split()
	l, b, h = int(s[0]), int(s[1]), int(s[2])
	edge = gcd(max(l,b,h),gcd(l+b+h-max(l,b,h)-min(l,b,h), min(l,b,h)))
	print(edge, end=' ')
	print(((l*b*h)/(edge**3))%1000000007)


def gcd(a, b):
	if b== 0:
		return a
	else:
		return gcd(b,a%b)
	


t= eval(input())
for _ in range(t):
	l,b,h = list(map(int,input().split()))
	a = gcd(gcd(l,b), h)
	ans = (l /a * b / a) % (10**9 + 7)
	ans = (ans * h / a) % (10**9 + 7)
	print(a, ans)



def gcd(a, b):
	if b==0:
		return a
	else:
		return gcd(b, a%b)

t=int(input())
while t>0:
	a,b,c=list(map(int,input().split()))
	d=gcd(a,b)
	side=gcd(c,d)
	num=((a*b*c)/(side**3))%1000000007
	print(str(side),str(num))
	t-=1


def gcd(m,n):
	if m%n == 0 :
		return n
	else:
		return gcd(n,m%n)
t = (int)(eval(input()))
for i in range(t):
	a,b,c = list(map(int,input().split()))
	d = gcd(gcd(a,b),c)
	res = (a/d * b/d * c/d) % 1000000007
	print(d,res)


from fractions import gcd
import sys
t = int(input())
i = 0
for i in range(0,t):
	a,b,c = list(map(int,sys.stdin.readline().split()))
	len_cube= gcd(gcd(a,b),c)
	num= (a*b*c)/(gcd(gcd(a,b),c)**3)%1000000007
	print(str(len_cube)+" "+str(num))


def GCD(a,b):
	if a==1 or b==1:
		return 1
	while b > 0:
		t = a % b
		a = b
		b = t
	return a
	
T=int(input())
for i in range(T):
	k=0
	l=0
	lst=[None]*3
	i=input()
	for j in i:
		if (j==' '):
			lst[k]=l
			l=0
			k=k+1
			continue
		l=(l*10)+int(j)
	lst[k]=l
	l=lst[0]
	b=lst[1]
	h=lst[2]
	a=GCD(l,GCD(b,h))
	print(str(a%1000000007)+" "+str(((l/a)*(b/a)*(h/a))%1000000007))


from fractions import gcd
MOD = 1000000007
for i in range(eval(input())):
	a,b,c = list(map(int,input().split()))
	ans1 = gcd(a,gcd(b,c))
	ans2 = ((a*b*c)/(ans1**3)) % MOD
	print(ans1, ans2)