PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000148. Tích trên đoạn có phải lập phương? (Cubic?)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Tích trên đoạn có phải lập phương? (Cubic?)

Cubic?

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

Given a sequence of positive integers A1,…,ANA_1,\ldots,A_N, a positive integer xx is called a perfect cube if there exists a positive integer yy such that x=y3x=y^3.

For each of QQ queries specifying a contiguous interval [L,R][L,R], determine whether AL⋯ARA_L\cdots A_R is a perfect cube. The product may be enormous; only its property must be reported.

Input

The first line contains N,QN,Q; the next line contains NN values AiA_i. Each of the next QQ lines contains L,RL,R satisfying 1≤L≤R≤N1\le L\le R\le N.

Output

For each query, print Yes if the product is a perfect cube, or No otherwise. The checker is case-insensitive.

Subtasks

  • Subtask 1 (20 points): 1≤N,Q≤301 \le N,Q \le 30; 1≤Ai≤1001 \le A_i \le 100.
  • Subtask 2 (30 points): 1≤N,Q≤50001 \le N,Q \le 5000; 1≤Ai≤1051 \le A_i \le 10^5.
  • Subtask 3 (50 points): 1≤N,Q≤2⋅1051 \le N,Q \le 2\cdot 10^5; 1≤Ai≤1061 \le A_i \le 10^6.

Examples

Input

8 5
7 49 30 1 15 8 6 10
1 2
2 3
4 4
5 8
3 8

Output

Yes
No
Yes
No
Yes

Explanation

7⋅49=343=737\cdot49=343=7^3 for [1,2][1,2]. The product of [2,3][2,3] is 14701470, not a cube. [4,4][4,4] is 1=131=1^3. The product of [5,8][5,8] is 72007200, not a cube; [3,8][3,8] gives 216000=603216000=60^3.