#SGM0000008. Giá trị xuất hiện nhiều nhất (Frequent Values)

Giá trị xuất hiện nhiều nhất (Frequent Values)

Frequent Values

Source: UVa

Version: Phuoc Hung OJ Extended

You are given a non-decreasing sequence A1,A2,…,ANA_1,A_2,\ldots,A_N. Each of the QQ queries gives two indices i,ji,j with 1≤i≤j≤N1\le i\le j\le N.

For every query, determine the largest frequency of any value among Ai,Ai+1,…,AjA_i,A_{i+1},\ldots,A_j.

The original UVa task contains multiple test cases terminated by a line containing 0. This Phuoc Hung OJ version contains one test case per input file.

Input

The first line contains N,QN,Q.

The second line contains the non-decreasing sequence A1,…,ANA_1,\ldots,A_N.

Each of the next QQ lines contains i,ji,j.

Output

For every query, print the maximum frequency in the requested range.

Subtasks

  • Subtask 1 — 20%: 1≤N,Q≤501\le N,Q\le 50, −1000≤Ai≤1000-1000\le A_i\le 1000.
  • Subtask 2 — 30%: 1≤N,Q≤50001\le N,Q\le 5000, −105≤Ai≤105-10^5\le A_i\le 10^5.
  • Subtask 3 — 50%: 1≤N,Q≤1051\le N,Q\le 10^5, −105≤Ai≤105-10^5\le A_i\le 10^5.

Examples

Input

10 3
-1 -1 1 1 1 1 3 10 10 10
2 3
1 10
5 10

Output

1
4
3

Explanation

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