#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
typedef long long ll;

const int NUM = 2e5+10;
ll x[NUM], y[NUM];
ll x00[NUM], y00[NUM];
ll x01[NUM], y01[NUM];
ll x10[NUM], y10[NUM];

int main() {
  int n;
  cin >> n;
  rep(i, n) cin >> x[i + 1] >> y [i + 1];
  int m;
  cin >> m;
  x10[0] = y01[0] = 1;
  rep(i, m) {
    int o; cin >> o;
    if(o == 1) {
      x00[i+1]=y00[i]; y00[i+1]=-x00[i];
      x01[i+1]=y01[i]; y01[i+1]=-x01[i];
      x10[i+1]=y10[i]; y10[i+1]=-x10[i];
    }
    if(o == 2) {
      x00[i+1]=-y00[i]; y00[i+1]=x00[i];
      x01[i+1]=-y01[i]; y01[i+1]=x01[i];
      x10[i+1]=-y10[i]; y10[i+1]=x10[i];
    }
    if(o == 3) {
      int p; cin >> p;
      x00[i+1]=2*p-x00[i]; y00[i+1]=y00[i];
      x01[i+1]=2*p-x01[i]; y01[i+1]=y01[i];
      x10[i+1]=2*p-x10[i]; y10[i+1]=y10[i];
    }
    if(o == 4) {
      int p; cin >> p;
      x00[i+1]=x00[i]; y00[i+1]=2*p-y00[i];
      x01[i+1]=x01[i]; y01[i+1]=2*p-y01[i];
      x10[i+1]=x10[i]; y10[i+1]=2*p-y10[i];
    }
  }
  int q; cin >> q;
  rep(i, q) {
    int a, b; cin >> a >> b;
    ll x_ = (x10[a]-x00[a])*x[b] + (x01[a]-x00[a])*y[b] + x00[a];
    ll y_ = (y10[a]-y00[a])*x[b] + (y01[a]-y00[a])*y[b] + y00[a];
    printf("%lld %lld\n", x_, y_);
  }
  return 0;
}

//kyoprosaikoooooooooooo!!
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007
double pai = 3.141592653589793238;
using namespace std;
//素数判定 O(√N)
ll prime (ll abc) {
  if (abc < 2) {
    return 0;
  }
  else if (abc == 2) {
    return 1;
  }
  else if (abc % 2 == 0) {
    return 0;
  }
  double sqrtabc = sqrt(abc);
  for (int i = 3; i <= sqrtabc; i++) {
    if (abc % i == 0) {
      return 0;
    }
  }
  return 1;
}
//素因数分解(約数列挙) O(√N)
vector<ll> divisor(ll n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
//小さい方に揃える
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
//大きい方に揃える
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
//繰り返し二乗法 O(logN)
ll pow(ll x, ll n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;  // n の最下位bitが 1 ならば x^(2^i) をかける
    x *= x;               //ret = ret * x % mod / x = x * x % mod でMODとれる
    n >>= 1;  // n を1bit 左にずらす
  }
  return ret;
}
struct Edge {
  ll to;
  ll w;
  Edge(ll to, ll w) : to(to) , w(w) {}
};
using Graph = vector<vector<Edge>>;
int main() {
  ll N, Q;
  cin >> N >> Q;
  set<ll> X;
  for (ll i = 0; i < N; i++) {
    ll a;
    cin >> a;
    X.insert(a);
  }
  vector<ll> A;
  for (ll v : X) {
    A.push_back(v);
  }
  ll SA = A.size();
  vector<ll> P;
  P.push_back(A[0] - 1);
  for (ll i = 1; i < SA; i++) {
    P.push_back(A[i] - A[i - 1] - 1);
  }
  vector<ll> L;
  ll sum = 0;
  for (ll n : P) {
    sum += n;
    L.push_back(sum);
  }
  for (ll i = 0; i < Q; i++) {
    ll j;
    cin >> j;
    ll O = lower_bound(L.begin(), L.end(), j) - L.begin();
    cout << j + O << endl;
  }
}