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

#SRD0000065. Thi bắn cung Robin Hood (Robin Hood Archery)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Thi bắn cung Robin Hood (Robin Hood Archery)

Robin Hood Archery

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn targets with scores aia_i. Robin Hood and the Sheriff alternate choosing an unused target, adding its score to their own total; Robin Hood moves first. Both play optimally. For every inclusive range [l,r][l,r], consider a separate game on only those targets. Print YES if the Sheriff can avoid losing (win or tie) with optimal play, otherwise NO.

Every query starts a fresh game with both scores reset to zero, and only the selected range of targets is available. Previous queries do not change future games.

Input

First line: n,qn,q; second line: nn integers aia_i; then qq query lines l,rl,r. No leading TT is used.

Output

For each query print YES or NO on its own line.

Subtasks

  • Subtask 1 (10 points): 1≤n≤801\le n\le 80; 1≤q≤901\le q\le 90; 1≤ai≤1 000 0001\le a_i\le 1\,000\,000; 1≤l≤r≤n1\le l\le r\le n.
  • Subtask 2 (20 points): 1≤n≤5 0001\le n\le 5\,000; 1≤q≤6 0001\le q\le 6\,000; 1≤ai≤1 000 0001\le a_i\le 1\,000\,000; 1≤l≤r≤n1\le l\le r\le n.
  • Subtask 3 (25 points): 1≤n≤50 0001\le n\le 50\,000; 1≤q≤60 0001\le q\le 60\,000; 1≤ai≤1 000 0001\le a_i\le 1\,000\,000; 1≤l≤r≤n1\le l\le r\le n.
  • Subtask 4 (45 points): 1≤n≤200 0001\le n\le 200\,000; 1≤q≤200 0001\le q\le 200\,000; 1≤ai≤1 000 0001\le a_i\le 1\,000\,000; 1≤l≤r≤n1\le l\le r\le n.

Examples

Input

3 3
1 2 2
1 2
1 3
2 3

Output

NO
NO
YES

Explanation

For [1,2][1,2] with scores 1,21,2, Robin Hood takes 22 and wins. In [1,3][1,3], the unmatched score 11 prevents a tie. In [2,3][2,3], the two targets both score 22, so the players tie and the answer is YES.