#P4752. Divided Prime
Divided Prime
Description
Given a number , where is obtained by multiplying .
Given a number , where is obtained by multiplying .
If is a prime number, output YES; otherwise, output NO.
Input Format
Each test point contains multiple test cases. The first line contains an integer , which denotes the number of test cases. For each test case:
The first line contains two integers , indicating that is obtained by multiplying numbers, and is obtained by multiplying numbers.
The second line contains integers, which are the numbers that make up .
The third line contains integers, which are the numbers that make up .
It is guaranteed that, for any number, the number of times it appears in is no more than the number of times it appears in .
Output Format
For each test case:
If is a prime number, output YES; otherwise, output NO.
After outputting YES or NO, output a newline character.
2
3 2
5 7 7
5 7
4 2
5 7 7 7
5 7
YES
NO
Hint
For all testdata, , , , , and .
Translated by ChatGPT 5
京公网安备 11011102002149号