Kth Query
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

MianKing has a sequence and he wants to answer queries about it.

Let denote the K-th smallest number of sequence which satisfies that .

Now for each query, give you , you need to answer .



输入描述:

The first line has two integers .

The second line has integers which denote  .

Then there are lines, the i-th line has three integers which represents the i-th query.









输出描述:

There are  lines, the i-th line has one integer which denotes .
示例1

输入

复制
3 3
1 2 3
0 4 1
0 4 2
0 4 3

输出

复制
0
1
2
示例2

输入

复制
5 4
0 1 2 3 4
2 3 4
4 5 1
2 2 3
1 4 5

输出

复制
3
0
2
5