___________________________________________________________________ the solution is yet to be found [Qəpik]
You are given an array of positive integers and a set of prime numbers. You have to make the array beautiful after applying the following operation any number of times:
The array is beautiful if there exist at least beautiful elements. An element is called beautiful if there exist an element such that and Here denotes the greatest common divisor of and
Can you make the array beautiful after applying the following operation any number of times.
The first line contains the number of test cases . For each test cases:
The first line contains two integer and — the size of array and the size of set respectively.
The second line contains positive integers — the elements of .
The third line contains distinct prime numbers — the elements of .
It is guaranteed that, over all test cases and .
If it is possible to make the array beautiful, print “Yes”, otherwise print “Roses”.
3 3 1 1 9 9 3 2 1 5 5 7 2 1 5 10 7
Yes Roses Yes
In the first test case, you can change one of the 9 to 1 dividing it by 3 two times. Thus final array is (1, 1, 9) which is a beautiful array.
In the second test case, there is no way to make the array beautiful.
In the third test case, the initial array is beautiful.