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

#PS0000110. Truy vấn tổng lẻ (Odd Queries)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Truy vấn tổng lẻ (Odd Queries)

Odd Queries

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Given an array a1,…,ana_1,\ldots,a_n, a query (l,r,k)(l,r,k) hypothetically sets every element at positions ll through rr to kk. Determine whether the resulting whole-array sum is odd. Every query starts from the original array; no query modifies subsequent queries.

Input

The first line contains integers n,qn,q.

The second line contains nn integers a1,…,ana_1,\ldots,a_n.

Each of the following qq lines contains three integers l,r,kl,r,k.

Output

Print qq lines, each containing YES for an odd resulting sum or NO otherwise. Letter case is ignored.

Subtasks

  • Subtask 1 (20 points): 1≤n≤10001\le n\le 1000; 1≤q≤10001\le q\le 1000; 1≤ai≤109, 1≤i≤n1\le a_i\le 10^9,\ 1\le i\le n; 1≤l≤r≤n1\le l\le r\le n; 1≤k≤1091\le k\le 10^9.
  • Subtask 2 (30 points): 1≤n≤2000001\le n\le 200000; 1≤q≤2000001\le q\le 200000; 1≤ai≤109, 1≤i≤n1\le a_i\le 10^9,\ 1\le i\le n; 1≤l≤r≤n1\le l\le r\le n; 1≤k≤1091\le k\le 10^9; r−l+1≤10r-l+1\le 10.
  • Subtask 3 (50 points): 1≤n≤2000001\le n\le 200000; 1≤q≤2000001\le q\le 200000; 1≤ai≤109, 1≤i≤n1\le a_i\le 10^9,\ 1\le i\le n; 1≤l≤r≤n1\le l\le r\le n; 1≤k≤1091\le k\le 10^9.

Examples 1

Input

5 5
2 2 1 3 2
2 3 3
2 3 4
1 5 5
1 4 9
2 4 3

Output

YES
YES
YES
NO
YES

Explanation

The original total is 10. The five independent replacements produce (2,3,3,3,2)(2,3,3,3,2), (2,4,4,3,2)(2,4,4,3,2), (5,5,5,5,5)(5,5,5,5,5), (9,9,9,9,2)(9,9,9,9,2) and (2,3,3,3,2)(2,3,3,3,2). Their totals are 13,15,25,38,1313,15,25,38,13. Only 38 is even, giving NO on line four and YES elsewhere.

Examples 2

Input

10 5
1 1 1 1 1 1 1 1 1 1
3 8 13
2 5 10
3 8 10
1 10 2
1 9 100

Output

NO
NO
NO
NO
YES

Explanation

The original total is 10. Replacement lengths are 6, 4, 6, 10, 9. The new sums are 82, 46, 64, 20, 901. Only the last sum is odd.