Given three integers x, y, z, the task is to compute the value of GCD(LCM(x,y), LCM(x,z)) and return the value.
Where, GCD = Greatest Common Divisor, LCM = Least Common Multiple.
Example 1:
Input: x = 15, y = 20, z = 100
Output: 60
Explanation: GCD(LCM(15,20), LCM(15,100))
=GCD(60,300)=60.
Ã¢â¬â¹Example 2:
Input: x = 30, y = 40, z = 400
Output: 120
Explanation: GCD(LCM(30,40), LCM(30,400))
=GCD(120,1200)=120.
Your Task:  
You don't need to read input or print anything. Your task is to complete the function findValue() which takes x, y, z as inputs and returns the answer.
Expected Time Complexity: O(max(log x, log y, log z))
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ x, y, z ≤ 10^{6}

Source: geeksforgeeks | Difficulty: EASY
Tags: Mathematics

Starter code: #User function Template for python3



class Solution:

    def findValue (self, x, y, z):

        #complete the function here

Solutions:
class Solution:

	def findValue(self, x, y, z):

		def gcd(a, b):
			if b == 0:
				return a
			else:
				return gcd(b, a % b)
		lcm1 = int(x * y / gcd(x, y))
		lcm2 = int(x * z / gcd(x, z))
		return gcd(lcm1, lcm2)


import math

class Solution:

	def findValue(self, x, y, z):
		a = x * y // math.gcd(x, y)
		b = x * z // math.gcd(x, z)
		return math.gcd(a, b)


class Solution:

	def findValue(self, x, y, z):
		return Solution.lcm(x, Solution.gcd(y, z))

	@staticmethod
	def gcd(a, b):
		if a == 0:
			return b
		return Solution.gcd(b % a, a)

	@staticmethod
	def lcm(a, b):
		return a * b // Solution.gcd(a, b)


from functools import reduce

class Solution:

	def findValue(self, x, y, z):
		gcd = lambda a, b: a if b == 0 else gcd(b, a % b)
		lcd = lambda a, b: int(a * b / gcd(a, b))
		return lcd(x, gcd(y, z))


class Solution:

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

	def findValue(self, x, y, z):
		lcmxy = x * y // self.gcd(x, y)
		lcmxz = x * z // self.gcd(x, z)
		return self.gcd(lcmxy, lcmxz)


import math

class Solution:

	def lcm(self, a, b):
		return a * b // math.gcd(a, b)

	def findValue(self, x, y, z):
		return math.gcd(self.lcm(x, y), self.lcm(x, z))
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		(x, y, z) = map(int, input().split())
		ob = Solution()
		print(ob.findValue(x, y, z))


class Solution:

	def gcd2(self, a, b):
		while a != b:
			if a > b:
				a -= b
			else:
				b -= a
		return a

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

	def findValue(self, x, y, z):
		gcdNum1 = self.gcd(x, y)
		gcdNum2 = self.gcd(x, z)
		lcm1 = int(x * y / gcdNum1)
		lcm2 = int(x * z / gcdNum2)
		grandGCD = self.gcd(lcm1, lcm2)
		return grandGCD


import math as m

class Solution:

	def findValue(self, x, y, z):
		g1 = m.gcd(x, y)
		g2 = m.gcd(x, z)
		l1 = x * y // g1
		l2 = x * z // g2
		g3 = m.gcd(l1, l2)
		return g3


import math as m

class Solution:

	def findValue(self, x, y, z):
		l = x * y // m.gcd(x, y - x)
		l1 = x * z // m.gcd(x, z - x)
		return m.gcd(l, l1)


class Solution:

	def gcd(self, a, b):
		while a != 0 and b != 0:
			if a < b:
				b = b % a
			else:
				a = a % b
		if a == 0:
			return b
		else:
			return a

	def findValue(self, x, y, z):
		m = x * y // self.gcd(x, y)
		n = x * z // self.gcd(x, z)
		return self.gcd(m, n)


class Solution:

	def gc(self, n, m):
		while n != 0 and m != 0:
			if n > m:
				n = n % m
			else:
				m = m % n
		if n == 0:
			return m
		else:
			return n

	def findValue(self, x, y, z):
		k = x * y // self.gc(x, y)
		c = x * z // self.gc(x, z)
		return self.gc(k, c)


class Solution:

	def findValue(self, x, y, z):

		def gcd(a, b):
			while b:
				(a, b) = (b, a % b)
			return a
		return gcd(x * y // gcd(x, y), x * z // gcd(x, z))


import math

class Solution:

	def findValue(self, x, y, z):
		k1 = x * y // math.gcd(x, y)
		k2 = x * z // math.gcd(x, z)
		return math.gcd(k1, k2)


import math

class Solution:

	def findValue(self, x, y, z):
		l1 = x * y // math.gcd(x, y)
		l2 = x * z // math.gcd(x, z)
		res = math.gcd(l1, l2)
		return res


class Solution:

	def gcd(self, x, y):
		return x if y == 0 else self.gcd(y, x % y)

	def findValue(self, x, y, z):
		return self.gcd(x // self.gcd(x, y) * y, x // self.gcd(x, z) * z)