#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define forn(i,x1,n)     for(int i=x1; i<n; i++)
#define forit(it, m)    for(decltype(m)::iterator it = m.begin(); it!=m.end(); ++it)
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x1)      __builtin_popcountll(x1)
#define zrobits(x1)      __builtin_ctzll(x1)
#define mod             1000000007
// #define mod             998244353
#define inf             1e18
#define ps(x1,y)         fixed<<setprecision(y)<<x1
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x1)            int x1; cin>>x1; while(x1--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());


void zeus()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}



int32_t main() {

	zeus();

	int a, b, c, d; cin >> a >> b >> c >> d;

	if (d * c - b <= 0) {
		cout << -1 << endl;
	}
	else {
		cout << ceil(1.0 * a / (d * c - b)) << endl;
	}



}
#include <vector>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i,n) for (int i=0; i<(n);++i)
ll mod=998244353,fac[200001],finv[200001],inv[200001];
int INF = 1e9+7;


mat matmul(mat &A,mat &B){
  mat C(A.size(),vec(B[0].size(),0));
  rep(i,A.size()){
    rep(j,B.size()){
      rep(k,B[0].size()){
        C[i][k] += A[i][j]*B[j][k];
      }
    }
  }
  
  return C;
}

int main(){
  ll n,m,q;
  cin >> n;
  vector<P> p(n);
  rep(i,n){
    int x,y;
    cin >> x >> y;
    p[i]=make_pair(x,y);
  }
  cin >> m;
  vector<mat> ma(m+1,mat(3,vec(3,0)));
  mat M = {{1,0,0},{0,1,0},{0,0,1},};
  ma[0] = M;
  for(int i=1;i<=m;i++){
    ll x,y;
    cin >> x;
    if(x>2) cin >> y;
    
    if(x==1){
      mat M = {{0,1,0},{-1,0,0},{0,0,1},};
      ma[i] = matmul(M,ma[i-1]);
    }
    else if(x==2){
      mat M = {{0,-1,0},{1,0,0},{0,0,1},};
      ma[i] = matmul(M,ma[i-1]);
    }
    else if(x==3){
      mat M = {{-1,0,2*y},{0,1,0},{0,0,1},};
      ma[i] = matmul(M,ma[i-1]);
    }
    else{
      mat M = {{1,0,0},{0,-1,2*y},{0,0,1},};
      ma[i] = matmul(M,ma[i-1]);
    }
  }
  cin >> q;
  rep(i,q){
    int a,b;
    cin >> a >> b;
    mat M(3,vec(1,0));
    M[0][0] = p[b-1].first;
    M[1][0] = p[b-1].second;
    M[2][0] = 1;
    mat v = matmul(ma[a],M);
    cout << v[0][0] << ' ' << v[1][0] << endl;
  }

}