#SGM0000015. Bash và bài toán GCD khó (Bash and a Tough Math Puzzle)

Bash và bài toán GCD khó (Bash and a Tough Math Puzzle)

Bash and a Tough Math Puzzle

Source: Codeforces

Version: Phuoc Hung OJ Extended

Given an array A1,A2,…,ANA_1,A_2,\ldots,A_N, process two query types:

  • 1 l r x: determine whether changing at most one element of [l,r][l,r] could make the gcd of the segment equal to xx. This hypothetical change does not modify the stored array.
  • 2 i y: actually assign Ai=yA_i=y.

For each type 1 query, print YES if the guess is almost correct and NO otherwise.

Input

The first line contains NN.

The second line contains A1,…,ANA_1,\ldots,A_N.

The third line contains QQ.

The next QQ lines describe the queries.

Output

For each type 1 query, print YES or NO.

Subtasks

  • Subtask 1 — 20%: 1≤N,Q≤501\le N,Q\le 50, 1≤Ai,x,y≤1041\le A_i,x,y\le 10^4.
  • Subtask 2 — 30%: 1≤N,Q≤50001\le N,Q\le 5000, 1≤Ai,x,y≤1091\le A_i,x,y\le 10^9.
  • Subtask 3 — 50%: 1≤N≤5⋅1051\le N\le 5\cdot10^5, 1≤Q≤4⋅1051\le Q\le 4\cdot10^5, 1≤Ai,x,y≤1091\le A_i,x,y\le 10^9.

Examples

Input

3
2 6 3
4
1 1 2 2
1 1 3 3
2 1 9
1 1 3 2

Output

YES
YES
NO

Explanation

The sample follows the operations exactly; each printed line corresponds to a query that requires output.