Please note that the memory limit differs from the standard.

You really love to listen to music. During the each of next *s* days you will listen to exactly *m* songs from the playlist that consists of exactly *n* songs. Let's number the songs from the playlist with numbers from 1 to *n*, inclusive. The quality of song number *i* is *a*<sub class="lower-index">*i*</sub>.

On the *i*-th day you choose some integer *v* (*l*<sub class="lower-index">*i*</sub> ≤ *v* ≤ *r*<sub class="lower-index">*i*</sub>) and listen to songs number *v*, *v* + 1, ..., *v* + *m* - 1. On the *i*-th day listening to one song with quality less than *q*<sub class="lower-index">*i*</sub> increases your displeasure by exactly one.

Determine what minimum displeasure you can get on each of the *s* next days.
The first line contains two positive integers *n*, *m* (1 ≤ *m* ≤ *n* ≤ 2·10<sup class="upper-index">5</sup>). The second line contains *n* positive integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> (0 ≤ *a*<sub class="lower-index">*i*</sub> &lt; 2<sup class="upper-index">30</sup>) — the description of songs from the playlist. 

The next line contains a single number *s* (1 ≤ *s* ≤ 2·10<sup class="upper-index">5</sup>) — the number of days that you consider.

The next *s* lines contain three integers each *l*<sub class="lower-index">*i*</sub>, *r*<sub class="lower-index">*i*</sub>, *x*<sub class="lower-index">*i*</sub> (1 ≤ *l*<sub class="lower-index">*i*</sub> ≤ *r*<sub class="lower-index">*i*</sub> ≤ *n* - *m* + 1; 0 ≤ *x*<sub class="lower-index">*i*</sub> &lt; 2<sup class="upper-index">30</sup>) — the description of the parameters for the *i*-th day. In order to calculate value *q*<sub class="lower-index">*i*</sub>, you need to use formula: <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/0c69e228d94a17aa3a7ef71f9fd7d69308cd1461.png" style="max-width: 100.0%;max-height: 100.0%;"/>, where *ans*<sub class="lower-index">*i*</sub> is the answer to the problem for day *i*. Assume that *ans*<sub class="lower-index">0</sub> = 0.
print("_RANDOM_GUESS_1689454260.8859065")# 1689454260.8859262