This page is still under construction.

Parts of this page are still being built. What you see may change.

Cryptographically Strong Keys

Time limit2sMemory limit256 MB

Summary
Given numbers a_i, the closure under gcd and lcm defines a set S; decide whether a query value v lies in S.
Level

Hard8 of 10

Topics
Number theory, Math, Greedy, Hash map
Solved
No attempts yet

Problem

Pasha has created his own data encryption protocol. In this protocol, the key used for encryption must belong to the set SS of cryptographically strong keys, which is built from a set of numbers a1,a2,…,ana_1, a_2, \ldots, a_n.

The set SS is the inclusion-minimal set with the following two properties:

  1. Every number a1,a2,…,ana_1, a_2, \ldots, a_n belongs to SS.
  2. If xx and yy belong to SS, then their greatest common divisor and their least common multiple also belong to SS.

Pasha wants to use the number vv as the key. Determine whether vv belongs to the set of cryptographically strong keys.

Input

The first line contains a positive integer TT, the number of test cases in the input. TT does not exceed 5. The descriptions of the test cases follow.

Each test case consists of three lines. The first line contains a positive integer nn (1≤n≤50 0001 \le n \le 50\,000). The second line contains nn numbers a1,a2,…,ana_1, a_2, \ldots, a_n (1≤ai≤10121 \le a_i \le 10^{12}). The third line contains the number vv (1≤v≤10121 \le v \le 10^{12}) whose membership in the set of cryptographically strong keys must be checked.

Output

For each of the TT test cases, output YES on a separate line if vv belongs to the set of cryptographically strong keys, and NO otherwise.

Examples1

  1. Example 1

    Input
    2
    2
    45 75
    15
    2
    45 75
    9
    
    Expected output
    YES
    NO