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 <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF (1LL<<60)
#define MOD 1000000007
inline void chmax(long long &x, long long v) { if (x < v) x = v; }

int N, M, T, Q;
long long dp[20][1000];
long long S[2][1000];
void merge(long long O[], long long A[], long long B[]) {
  rep(a, T) {
    if (A[a] == -INF) continue;
    rep(b, T) {
      if (B[b] == -INF) continue;
      chmax(O[(a+b)%T], A[a]+B[b]);
    }
  }
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> M >> T;
  rep(k, 20) rep(i, T) dp[k][i] = -INF;
  dp[0][0] = 0;
  rep(i, N) {
    int a;
    cin >> a;
    chmax(dp[0][a%T], a);
  }
  rep(k, 19) merge(dp[k+1], dp[k], dp[k]);

  rep(i, T) S[0][i] = -INF; S[0][0] = 0;
  rep(k, 20) if ((M>>k)&1) {
    rep(i, T) S[1][i] = -INF;
    merge(S[1], S[0], dp[k]);
    swap(S[0], S[1]);
  }

  for (int i=T-2; i>=0; i--) chmax(S[0][i], S[0][i+1]);
  cin >> Q;
  rep(i, Q) {
    int a, b;
    cin >> a >> b;
    if (S[0][a] >= 1LL*T*b) cout << "yes\n";
    else cout << "no\n";
  }
  return 0;
}