The MarkiT online virtual market startup wants to organize its grand opening in NIT Patna.
but they want maximum crowd for their inauguration. So the manager told  this  to Praveen a student in NITP who suggested them:
The first-year students come to campus  every x hour,
Second-year students come to campus every y hour,
Third-year students come to campus every z hour and 
Fourth-year is very busy so they don't come regularly.
So Praveen being very clever told him the no of times in n days he can have an audience of all year student (1st,2nd & 3rd) at max. So can you code what Praveen has done?

-----Input:-----
- First line will contain $T$, number of testcases. Then the testcases follow. 
- Each testcase contains of a 2 line of input, first line contain one  integers $N$ (No of Days). 
-Next line contain 3 space separated integer the  value of x y z

-----Output:-----
For each testcase, output in a single line answer the no of times audience consists of all year.

-----Constraints-----
- $1 \leq T \leq 1000$
- $1 \leq N \leq 10^8$
- $1 \leq x,y,z \leq 10^5$

-----Sample Input:-----
1
10
8 10 6

-----Sample Output:-----
2

-----EXPLANATION:-----
First favourable condition will come on 5th day and Second on 10th day.

Source: codechef | Difficulty: UNKNOWN_DIFFICULTY


Solutions:
import math

def fun(num1, num2):
	if num1 > num2:
		a = num1
		b = num2
	else:
		a = num2
		b = num1
	rem = a % b
	while rem != 0:
		a = b
		b = rem
		rem = a % b
	gcd = b
	return int(num1 * num2 / gcd)
for _ in range(int(input())):
	hours = int(input()) * 24
	(x, y, z) = list(map(int, input().split()))
	lcm = x
	lcm = fun(x, y)
	lcm = fun(lcm, z)
	print(int(hours // lcm))


from math import gcd
for ii in range(int(input())):
	N = int(input())
	N *= 24
	X = input().split()
	(x, y, z) = (int(X[0]), int(X[1]), int(X[2]))
	a = [x, y, z]
	lcm = a[0]
	for i in a[1:]:
		lcm = lcm * i // gcd(lcm, i)
	print(N // lcm)


def find_lcm(num1, num2):
	if num1 > num2:
		num = num1
		den = num2
	else:
		num = num2
		den = num1
	rem = num % den
	while rem != 0:
		num = den
		den = rem
		rem = num % den
	gcd = den
	lcm = int(int(num1 * num2) / int(gcd))
	return lcm
import math
t = int(input())
for j in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	num1 = l[0]
	num2 = l[1]
	lcm = find_lcm(num1, num2)
	for i in range(2, len(l)):
		lcm = find_lcm(lcm, l[i])
	print(math.floor(24 * n / lcm))


def find_lcm(num1, num2):
	if num1 > num2:
		num = num1
		den = num2
	else:
		num = num2
		den = num1
	rem = num % den
	while rem != 0:
		num = den
		den = rem
		rem = num % den
	gcd = den
	lcm = int(int(num1 * num2) / int(gcd))
	return lcm
for _ in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	num1 = x[0]
	num2 = x[1]
	lcm = find_lcm(num1, num2)
	lcm = find_lcm(lcm, x[2])
	n = n * 24
	print(int(n / lcm))


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

def lcm(a, b):
	return a * b / gcd(a, b)
for _ in range(int(input())):
	n = int(input())
	(x, y, z) = list(map(int, input().split()))
	total = n * 24
	first = lcm(x, y)
	final = lcm(first, z)
	ans = int(total / final)
	print(ans)


def find_lcm(num1, num2):
	if num1 > num2:
		num = num1
		den = num2
	else:
		num = num2
		den = num1
	rem = num % den
	while rem != 0:
		num = den
		den = rem
		rem = num % den
	gcd = den
	lcm = int(int(num1 * num2) / int(gcd))
	return lcm

def crowd(days, x, y, z):
	hrs = days * 24
	abc = find_lcm(x, y)
	abc = find_lcm(abc, z)
	return hrs // abc
t = int(input())
nodays = []
a = []
b = []
c = []
for i in range(t):
	nodays.append(int(input()))
	(d, e, f) = map(int, input().split())
	a.append(d)
	b.append(e)
	c.append(f)
for i in range(t):
	print(crowd(nodays[i], a[i], b[i], c[i]))


from math import gcd

def lcm(a, b):
	return a * b // gcd(a, b)
for a0 in range(int(input())):
	n = int(input())
	haha = list(map(int, input().split()))
	x = haha[0]
	for i in range(1, 3):
		x = lcm(x, haha[i])
	x /= 24
	print(int(n // x))


def findlcm(num1, num2):
	if num1 > num2:
		num = num1
		den = num2
	else:
		num = num2
		den = num1
	rem = num % den
	while rem != 0:
		num = den
		den = rem
		rem = num % den
	gcd = den
	lcm = int(int(num1 * num2) / int(gcd))
	return lcm
for t in range(int(input())):
	n = int(input())
	(x, y, z) = list(map(int, input().split()))
	lcm = findlcm(findlcm(x, y), z)
	print(int(24 * n / lcm))


import math

def lcm(x, y, z):
	s = x * y
	p = s // math.gcd(x, y)
	s = p * z
	p = s // math.gcd(p, z)
	return p
for _ in range(int(input())):
	n = int(input())
	(x, y, z) = list(map(int, input().split()))
	z = lcm(x, y, z)
	x = n * 24 // z
	print(x)


def find_lcm(num1, num2):
	if num1 > num2:
		num = num1
		den = num2
	else:
		num = num2
		den = num1
	rem = num % den
	while rem != 0:
		num = den
		den = rem
		rem = num % den
	gcd = den
	lcm = int(int(num1 * num2) / int(gcd))
	return lcm
s = int(input())
for i in range(s):
	n = int(input())
	n = n * 24
	li = list(map(int, input().split(' ')))
	num1 = li[0]
	num2 = li[1]
	lcm = find_lcm(num1, num2)
	for i in range(2, len(li)):
		lcm = find_lcm(lcm, li[i])
	print(int(n / lcm))


from sys import stdin
from math import gcd
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	(x, y, z) = list(map(int, stdin.readline().split()))
	lcm1 = x * y // gcd(x, y)
	lcm2 = lcm1 * z // gcd(lcm1, z)
	total = 24 * n
	print(total // lcm2)


import math
from math import gcd

def prime(n):
	if n <= 1:
		return False
	max_div = math.floor(math.sqrt(n))
	for i in range(2, 1 + max_div):
		if n % i == 0:
			return False
	return True
t = int(input())
for rr in range(t):
	n = int(input()) * 24
	(x, y, z) = list(map(int, input().split(' ')))

	def find_lcm(num1, num2):
		if num1 > num2:
			num = num1
			den = num2
		else:
			num = num2
			den = num1
		rem = num % den
		while rem != 0:
			num = den
			den = rem
			rem = num % den
		gcd = den
		lcm = int(int(num1 * num2) / int(gcd))
		return lcm
	l = [x, y, z]
	num1 = l[0]
	num2 = l[1]
	lcm = find_lcm(num1, num2)
	for i in range(2, len(l)):
		lcm = find_lcm(lcm, l[i])
	print(n // lcm)


t = int(input())
n = []
l = []

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


from math import gcd
from functools import reduce

def lcm(denominators):
	return reduce(lambda a, b: a * b // gcd(a, b), denominators)
T = int(input())
for _ in range(T):
	n = int(input())
	text = input()
	list = [int(n) for n in text.split()]
	lcm_ans = lcm(list)
	print(n * 24 // lcm_ans)


def gcd(a, b):
	while b > 0:
		(a, b) = (b, a % b)
	return a

def lcm(a, b):
	return a * b / gcd(a, b)
t = int(input())
for _ in range(t):
	n = int(input())
	(a, b, c) = map(int, input().split())
	aa = lcm(a, b)
	temp = lcm(aa, c)
	ans = n * 24 // temp
	print(int(ans))


from functools import reduce
from math import gcd

def lcm(a, b):
	return int(a * b / gcd(a, b))

def lcms(*numbers):
	return reduce(lcm, numbers)
for _ in range(int(input())):
	d = int(input())
	num = list(map(int, input().split()))
	x = lcms(*num) / 24
	print(int(d // x))


import math

def compute_lcm(x, y):
	return x * y // math.gcd(x, y)
T = int(input())
for i in range(T):
	N = int(input())
	(x, y, z) = list(map(int, input().strip().split()))
	lcm = compute_lcm(compute_lcm(x, y), z)
	print(N * 24 // lcm)


from math import gcd
from functools import reduce

def lcm(denominators):
	return reduce(lambda a, b: a * b // gcd(a, b), denominators)
try:
	for testcase in range(int(input())):
		d = int(input())
		(f, s, t) = list(map(int, input().split()))
		a = lcm([f, s, t])
		c = 24 * d // a
		print(c)
except:
	EOFError


def find_lcm(num1, num2):
	if num1 > num2:
		num = num1
		den = num2
	else:
		num = num2
		den = num1
	rem = num % den
	while rem != 0:
		num = den
		den = rem
		rem = num % den
	gcd = den
	lcm = int(int(num1 * num2) / int(gcd))
	return lcm
T = int(input())
for r in range(T):
	N = int(input())
	l = [int(x) for x in input().split()]
	num1 = l[0]
	num2 = l[1]
	lcm = find_lcm(num1, num2)
	for i in range(2, len(l)):
		lcm = find_lcm(lcm, l[i])
		hour = 24 * N
		ans = hour // lcm
		print(ans)


from math import gcd
from functools import reduce

def lcm(denominators):
	return reduce(lambda a, b: a * b // gcd(a, b), denominators)
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	res = lcm(arr)
	hrs = 24 * n
	print(hrs // res)


from math import gcd, sqrt

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def si():
	return input()
t = ii()
while t:
	t -= 1
	n = ii()
	n *= 24
	(x, y, z) = mi()
	s = gcd(x, y)
	s1 = x * y // s
	s = gcd(s1, z)
	s1 = s1 * z // s
	print(n // s1)


t = int(input())

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

def lcm(a, b):
	return a * b / gcd(a, b)
for _ in range(t):
	n = int(input())
	(x, y, z) = map(int, input().split(' '))
	count = 0
	p = lcm(x, y)
	p = lcm(p, z)
	print(int(24 * n / p))