You've got an array, consisting of *n* integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub>. Also, you've got *m* queries, the *i*-th query is described by two integers *l*<sub class="lower-index">*i*</sub>, *r*<sub class="lower-index">*i*</sub>. Numbers *l*<sub class="lower-index">*i*</sub>, *r*<sub class="lower-index">*i*</sub> define a subsegment of the original array, that is, the sequence of numbers *a*<sub class="lower-index">*l*<sub class="lower-index">*i*</sub></sub>, *a*<sub class="lower-index">*l*<sub class="lower-index">*i*</sub> + 1</sub>, *a*<sub class="lower-index">*l*<sub class="lower-index">*i*</sub> + 2</sub>, ..., *a*<sub class="lower-index">*r*<sub class="lower-index">*i*</sub></sub>. For each query you should check whether the corresponding segment is a ladder. 

A ladder is a sequence of integers *b*<sub class="lower-index">1</sub>, *b*<sub class="lower-index">2</sub>, ..., *b*<sub class="lower-index">*k*</sub>, such that it first doesn't decrease, then doesn't increase. In other words, there is such integer *x* (1 ≤ *x* ≤ *k*), that the following inequation fulfills: *b*<sub class="lower-index">1</sub> ≤ *b*<sub class="lower-index">2</sub> ≤ ... ≤ *b*<sub class="lower-index">*x*</sub> ≥ *b*<sub class="lower-index">*x* + 1</sub> ≥ *b*<sub class="lower-index">*x* + 2</sub>... ≥ *b*<sub class="lower-index">*k*</sub>. Note that the non-decreasing and the non-increasing sequences are also considered ladders.
The first line contains two integers *n* and *m* (1 ≤ *n*, *m* ≤ 10<sup class="upper-index">5</sup>) — the number of array elements and the number of queries. The second line contains the sequence of integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> (1 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">9</sup>), where number *a*<sub class="lower-index">*i*</sub> stands for the *i*-th array element.

The following *m* lines contain the description of the queries. The *i*-th line contains the description of the *i*-th query, consisting of two integers *l*<sub class="lower-index">*i*</sub>, *r*<sub class="lower-index">*i*</sub> (1 ≤ *l*<sub class="lower-index">*i*</sub> ≤ *r*<sub class="lower-index">*i*</sub> ≤ *n*) — the boundaries of the subsegment of the initial array.

The numbers in the lines are separated by single spaces.
def binpoisk(a, x):
    l, r = -1, len(a)
    while l + 1 < r:
        m= (l + r) // 2
        if a[m][0] <= x <= a[m][1]:
            return m
        if a[m][1] < x:
            l = m
        elif a[m][0] > x:
            r = m

def main():
    n, m = list(map(int, input().split()))
    a = list(map(int, input().split()))
    i_u, i_l, l, cnt = [], [], 0, 1
    for i in range(n-1):
        if a[i] < a[i+1]:
            i_l.append([l, l + cnt - 1])
            l, cnt = i+1, 1
        else:
            cnt += 1
    i_l.append([l, l+cnt-1])
    l, cnt = 0, 1

    for i in range(n-1):
        if a[i] > a[i+1]:
            i_u.append([l, l + cnt-1])
            l, cnt = i+1, 1
        else:
            cnt += 1
    i_u.append([l, l + cnt - 1])
    print(*i_u)
    print(*i_l)
    for i in range(m):
        li, ri = list(map(int, input().split()))
        li -= 1
        ri -= 1
        index1 = binpoisk(i_u, li)
        index2 = binpoisk(i_l, ri)
        l1, r1, l2, r2 = i_u[index1][0], i_u[index1][1], i_l[index2][0], i_l[index2][1]
        if r1 - li + ri - l2 + 2 >= ri - li + 1:
            print('Yes')
        else:
            print('No')


if __name__ == "__main__":
    main()