Consider a number X on which K Mag-Inc operations are to be performed. In a Mag-Inc operation, the number X undergoes an increment of A/B times of X where A and B are two integers.

There is a numerator and a denominator array of size K which contain the ith values of A and B. After K Mag-Inc operations, the number X turns to M.

Now your job is to find what percentage of M is to be decremented from M if it has to be converted back to X. Let this percentage be denoted by Z.

Print the integral part of Z.

-----Input:-----

First line contains an integer T denoting the number of test cases.

First line of every test case contains two space separated integers X and K.

The second and third line of every test case will contain K space separated integers 

denoting the Numerator and Denominator array.

-----Output:-----

For each test case, print the required result in a single line.

-----Constraints:-----
1 ≤ T ≤ 100
1 ≤ K, A, B ≤ 40000
1≤X≤10^100

-----Example:-----Input:
2
100 1
1 
4
100 2
1 1
2 3Output:
20
50

-----Explanation:-----

Case 2: 100 undergoes an increment of (1/2)*100. Therefore M = 100 + 50.

Now M = 150.

Now again, 

M undergoes an increment of (1/3)*150. Therefore, M = 150 + 50. 

Now as we want to revert back M = 200 to X i.e. 100, we need to decrement it by a value 

of 100 and we know that 100 is 50% of 200.

Hence, we print 50.

Difficulty: UNKNOWN_DIFFICULTY

Starter code:

Solutions:
import sys
import math

def solution():
	T = int(input().strip())
	for _ in range(T):
		(x, k) = list(map(float, input().strip().split(' ')))
		original_x = x
		if k == 1:
			a = [float(input().strip())]
			b = [float(input().strip())]
		else:
			a = list(map(float, input().strip().split(' ')))
			b = list(map(float, input().strip().split(' ')))
		for i in range(int(k)):
			x = x + a[i] / b[i] * x
		percentage = (x - original_x) / x * 100
		print('%d' % int(percentage))
solution()


import sys
T = int(sys.stdin.readline())
while T:
	(n, k) = list(map(int, input().split()))
	num = list(map(int, sys.stdin.readline().split()))
	den = list(map(int, sys.stdin.readline().split()))
	ans = n
	for i in range(k):
		ans += ans * num[i] / float(den[i])
	print(int(100 - 100 * n / ans))
	T -= 1


t = int(input())
for i in range(t):
	(value, k) = list(map(int, input().split()))
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	newValue = value
	for j in range(k):
		temp = newValue * float(A[j]) / B[j]
		newValue += temp
	error = value * 100 / newValue
	print(int(100 - error))


t = int(input())
for tc in range(0, t):
	(n, k) = list(map(int, input().split()))
	num = list(map(int, input().split()))
	den = list(map(int, input().split()))
	temp = n
	for i in range(0, k):
		temp = temp + temp ** 1.0 * num[i] / den[i]
	answer = int(100 - n * 1.0 * 100 / temp)
	print(answer)


t = eval(input())
while t:
	t -= 1
	(x, k) = list(map(int, input().split()))
	a = list(map(float, input().split()))
	b = list(map(float, input().split()))
	rat = 1.0
	for i in range(k):
		rat = rat * ((a[i] + b[i]) / b[i])
	rat = (rat - 1) / rat * 100.0
	print(int(rat))


t = float(input())
while t:
	t -= 1
	(x, k) = list(map(float, input().split()))
	k = int(k)
	a = list(map(float, input().split()))
	b = list(map(float, input().split()))
	temp = x
	for i in range(0, k):
		xxx = temp * a[i] / b[i]
		temp += xxx
	px = (temp - x) / temp * 100.0
	print(int(px))


for _i in range(int(input())):
	(x, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	l = []
	l.append(x)
	for i in range(k):
		x = x + x * (float(a[i]) / b[i])
	w = l[0]
	perc = 100 * (float(w) / x)
	ans = 100 - perc
	print(int(ans))