Problem: A lottery is being held in a corner of the venue of the Aizu festival. Several types of balls are inside the lottery box and each type has its unique integer printed on the surfaces of the balls. An integer T is printed on the lottery box.

In the lottery, you first declare two integers A and B, and draw up to M balls from the box. Let the sum of the integers printed on the balls be S. You can get a wonderful gift if the following two criteria are met: S divided by T gives a remainder greater than or equal to A, and S divided by T gives a quotient (fractional portion dropped) greater than or equal to B.

Write a program to determine if you have any chance of getting the gift given the following information: the number of ball types, ball-type specific integers, the maximum number of balls to be drawn from the box, the integer printed on the lottery box, and two integers declared before drawing. Assume that each ball type has sufficient (≥M) population in the box. Note also that there may be a chance of getting the gift even without drawing any ball.



Input

The input is given in the following format.


N M T
a_1
a_2
:
a_N
Q
A_1 B_1
A_2 B_2
:
A_Q B_Q


The first line provides the number of ball types N(1≤N≤105), the maximum number of balls you can draw from the box M(1≤M≤105), and the integer printed on the box T(1≤T≤1000). Each of the subsequent N lines provides an integer a_i (1≤a_i≤109) printed on the i-th ball type. The next line following these provides the number of declarations Q (1≤Q≤105). Each of the Q lines following this provides a pair of integers A_i (0 ≤ A_i < T), B_i (0 ≤ B_i ≤ 109) that constitute the i-th declaration.

Output

Output a line for each pair of declaration A and B that contains "yes" if there is a chance of getting the gift or "no" otherwise.

Example

Input

3 2 7
8
3
6
5
2 2
3 2
4 1
6 1
6 0


Output

yes
no
yes
no
yes

Solution (in CPP):

Solution:
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

int main() {
	int n, m, t; std::cin >> n >> m >> t;
	std::vector<int> balls(n); for (auto& a : balls) std::cin >> a;
	std::vector<std::vector<long long int>> max_b{ std::vector<long long int>(t, -1) };
	for (const auto a : balls) {
		max_b[0][a % t] = std::max(max_b[0][a % t], (long long int)a / t);
	}
	for (auto _c = 1; (1 << _c) <= m; ++_c) {
		std::vector<long long int> last(t, -1);
		for (auto i = 0; i < t; ++i) if (max_b.back()[i] != -1) {
			for (auto j = 0; j <= i; ++j) if (max_b.back()[j] != -1) {
				last[(i + j) % t] = std::max(last[(i + j) % t], max_b.back()[i] + max_b.back()[j] + (i + j) / t);
			}
		}
		max_b.push_back(std::move(last));
	}
	auto result = max_b.back();
	for (auto i = 0; i + 1 < max_b.size(); ++i) if ((m & (1 << i)) != 0) {
		auto last = result;
		for (auto j = 0; j < t; ++j) if (max_b[i][j] != -1) {
			for (auto k = 0; k < t; ++k) if (last[k] != -1) {
				result[(j + k) % t] = std::max(result[(j + k) % t], max_b[i][j] + last[k] + (j + k) / t);
			}
		}
	}
	for (auto i = 2; i <= result.size(); ++i) {
		result[result.size() - i] = std::max(result[result.size() - i], result[result.size() - i + 1]);
	}
	int q; std::cin >> q;
	for (auto i = 0; i < q; ++i) {
		int a, b; std::cin >> a >> b;
		std::cout << (result[a] >= b ? "yes\n" : "no\n");
	}
}