#C1454. Gem Collection and Prime Sums

    ID: 44200 Type: Default 1000ms 256MiB

Gem Collection and Prime Sums

Gem Collection and Prime Sums

You are given t test cases. In each test case, you are provided with information on n castles. Each castle has a position and holds a gem with a certain value. Your task is to determine whether there exists a pair of gems (from two different castles) such that the sum of their values is a prime number.

A prime number is defined as an integer \( p > 1 \) such that its only positive divisors are 1 and \( p \) itself. For instance, 2, 3, 5, and 7 are prime numbers.

If there is at least one pair of gems whose sum is prime, output YES for that test case; otherwise, output NO.

Note: The positions of the castles are provided but are not used in determining the answer.

inputFormat

The input is read from stdin and has the following format:

T
n
pos₁ pos₂ ... posₙ
gem₁ gem₂ ... gemₙ
... (repeated for T test cases)

Where:

  • T is the number of test cases.
  • For each test case, n is the number of castles.
  • The next line contains n integers representing the positions of the castles (this information is not used in solving the problem).
  • The following line contains n integers representing the values of the gems located at each castle.

outputFormat

For each test case, output a single line to stdout containing either YES or NO depending on whether there exists at least one pair of gems with a prime sum.

## sample
3
4
1 2 3 4
2 3 5 7
3
10 20 30
11 13 17
3
10 20 30
1 4 6
YES

NO YES

</p>