The cartesian tree of a sequence of distinct integers, is an unique binary tree defined as follows.
In a binary tree, the depth of a node is defined as the distance from the root to the node.
You are given a permutation $p$ of elements $1,2,\cdots,n$. You must solve $q$ queries of the following kind.
The first line contains two integers $n$ and $q$ ($1 \leq n, q \leq 10^6$) --- the length of the permutation and number of queries respectively.
The second line contains $n$ distinct integers $p_1, p_2, \cdots, p_n$ ($1 \leq p_i \leq n$) --- the permutation $p$.
The next $q$ lines contain two integers $l_i, r_i$ ($1 \leq l_i \leq r_i \leq n$) --- the bounds of query $i$.
For each query, output the answer on a new line.