Given four numbers X, Y, Z and N. Your task is to find smallest N digit Number that is divisible by all the three numbers X, Y and Z.
Note: If no such number can be formed then print "-1".
The first line of the input contains an integer T, denoting the number of test cases. Then T test case follows. The only line of each test case contains four space separated integers denoting the values of X, Y, Z and N respectively.
Output:For each test case output the smallest N digit number divisible by X, Y and Z. If no such number can be formed then print "-1".
1 <= T <= 103
1 <= X,Y,Z <= 103
1 <= N <= 18
2 3 5 4
4 5 6 3
3 5 7 2
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.