#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define DEBUG
#ifdef DEBUG
inline void debug_print() { cerr << endl; }
template <typename T1, typename... T2> void debug_print(const T1 a, const T2 &... b) { cerr << a << ' '; debug_print(b...); }
#define debug(...) cerr << __LINE__ << ": [" << #__VA_ARGS__ << "] = " , debug_print(__VA_ARGS__);
#else
#define debug(...) true
#endif

inline void print() { cout << '\n'; }
template <typename T1, typename... T2> void print(const T1 a, const T2 &... b) { cout << a << ' '; print(b...); }

template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto e : v) os << e << ' '; return os; }
template <typename T> ostream &operator<<(ostream &os, const set<T> &v) { for (auto e : v) os << e << ' ';  return os; }
template <typename T> ostream &operator<<(ostream &os, const multiset<T> &v) { for (auto e : v) os << e << ' ';  return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp) { for (auto e : mp) os << e << ' '; return os; }

template <typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } else return false; }
template <typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } else return false; }

const int INF = (1<<30)-1;
const long long LINF = 1LL<<60;
const double EPS = 1e-9;
const int MOD = 1000000007;
//const int MOD = 998244353;
const int dx[8] = {-1,0,1,0,1,-1,1,-1};
const int dy[8] = {0,1,0,-1,1,-1,-1,1};

//-------------------------- Libraries --------------------------//

//--------------------------- Solver ----------------------------//

void solve() {
    int N;
    cin >> N;
    pair<double, double> p0, p2;
    cin >> p0.first >> p0.second;
    cin >> p2.first >> p2.second;

    pair<double, double> o = {(p0.first+p2.first)/2, (p0.second+p2.second)/2};

    p0.first -= o.first;
    p0.second -= o.second;

    double theta = 2*M_PI / N;

    pair<double, double> p1;
    p1.first = p0.first * cos(theta) - p0.second * sin(theta);
    p1.second = p0.first * sin(theta) + p0.second * cos(theta);

    p1.first += o.first;
    p1.second += o.second;

    print(p1.first, p1.second);
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int t = 1;
    //cin >> t;
    while (t--) solve();

    return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

typedef vector<vector<ll>> mat;

void print(mat A){
	rep(i, A.size()){
		rep(j, A[i].size()){
			cout << A[i][j] << (j == A[i].size()-1 ? "\n" : " ");
		}
	}
}

mat mmul(mat A, mat B){
	int n = A.size();
	int l = A[0].size();
	int m = B[0].size();
	mat C(n, vector<ll>(m, 0));
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			for(int k = 0; k < l; k++){
				C[i][j] += A[i][k] * B[k][j];
			}
		}
	}

	return C;
}

mat mE(int n){
	mat A(n, vector<ll>(n, 0));
	for(int i = 0; i < n; i++){
		A[i][i] = 1LL;
	}

	return A;
}

mat mpow(mat A, ll x){
	int n = A.size();
	if(x == 0) return mE(n);
	if(x % 2 == 1) return mmul(A, mpow(A, x - 1));

	mat B = mpow(A, x / 2);
	return mmul(B, B);
}

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll n;
	cin >> n;

	vector<ll> x(n), y(n);
	rep(i, n) cin >> x[i] >> y[i];

	mat A1 = vector<vector<ll>>(3, vector<ll>(3, 0));
	A1[0][1] = 1;
	A1[1][0] = -1;
	A1[2][2] = 1;

	mat A2 = vector<vector<ll>>(3, vector<ll>(3, 0));
	A2[0][1] = -1;
	A2[1][0] = 1;
	A2[2][2] = 1;

	mat A3 = mE(3);
	A3[0][0] = -1;

	mat A4 = mE(3);
	A4[1][1] = -1;

	vector<mat> A;
	A.push_back(mE(3));

	ll m;
	cin >> m;

	rep(i, m){
		int t;
		cin >> t;

		if(t == 1){
			A.push_back(mmul(A1, A[i]));
		}else if(t == 2){
			A.push_back(mmul(A2, A[i]));
		}else if(t == 3){
			int p;
			cin >> p;

			A3[0][2] = 2 * p;
			A.push_back(mmul(A3, A[i]));
		}else{
			int p;
			cin >> p;
	
			A4[1][2] = 2 * p;
			A.push_back(mmul(A4, A[i]));
		}
	}

	mat t = {{0}, {0}, {1}};
	int q;
	cin >> q;

	vector<ll> a(q), b(q);
	rep(i, q){
		cin >> a[i] >> b[i];
		b[i]--;
	}

	rep(i, q){
		t[0][0] = x[b[i]];
		t[1][0] = y[b[i]];
		mat B = mmul(A[a[i]], t);

		cout << B[0][0] << " " << B[1][0] << endl;
	}
}
