#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, st, n) for (int i = (st); i < (n); ++i)
#define rrep(i, n) for (int i > (n)-1; i >= 0; ++i)
#define RREP(i, st, n) for (int i = (st); i > (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

template <class T>
class Matrix {
 public:
  int h, w;
  V<V<T>> data;
  Matrix(int h_, int w_ = 0, T v = 0) {
    h = h_;
    w = (w != 0) ? w_ : h;
    data.resize(h);
    rep(i, h) data[i].resize(w, v);
  }
  Matrix(const V<V<T>>& data_)
      : h(data_.size()), w(data_[0].size), data(data_) {}
  Matrix(initializer_list<initializer_list<T>> list) {
    data.resize(list.size());
    int cnt = 0;
    for (auto row : list) data[cnt++] = V<T>(row);
    h = data.size(), w = data[0].size();
  }
  Matrix(const Matrix& a) : h(a.h), w(a.w), data(a.data) {}
  Matrix& operator=(const Matrix& a) {
    h = a.h, w = a.w, data = a.data;
    return *this;
  }
  V<T>& operator[](int n) { return data[n]; }
  Matrix& operator*=(Matrix& a) {
    V<V<T>> res(h, V<T>(a.w));
    rep(i, h) rep(j, a.w) {
      rep(k, w) res[i][j] += data[i][k] * a[k][j];
    }
    swap(data, res);
    w = a.w;
    return *this;
  }
  Matrix operator*(Matrix& a) { return Matrix(*this) *= a; }
  Matrix& operator+=(Matrix& a) {
    rep(i, h) rep(j, w) data[i][j] += a[i][j];
    return *this;
  }
  string str() {
    ostringstream oss;
    rep(i, h) {
      rep(j, w) oss << data[i][j] << " ";
      if (i != h - 1) oss << "\n";
    }
    return oss.str();
  }
};

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

  int n, m;
  cin >> n;

  V<P> xy(n);
  rep(i, n) cin >> xy[i].first >> xy[i].second;

  V<Matrix<ll>> ops;
  Matrix<ll> now = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
  ops.push_back(now);
  Matrix<ll> clk = {{0, 1, 0}, {-1, 0, 0}, {0, 0, 1}};
  Matrix<ll> clw = {{0, -1, 0}, {1, 0, 0}, {0, 0, 1}};
  Matrix<ll> f3 = {{-1, 0, 2}, {0, 1, 0}, {0, 0, 1}};
  Matrix<ll> f4 = {{1, 0, 0}, {0, -1, 2}, {0, 0, 1}};

  cin >> m;
  rep(i, m) {
    int op;
    ll p;
    cin >> op;
    if (op > 2) cin >> p;

    if (op == 1) {
      now = clk * now;
    } else if (op == 2) {
      now = clw * now;
    } else if (op == 3) {
      f3[0][2] = 2 * p;
      now = f3 * now;
    } else if (op == 4) {
      f4[1][2] = 2 * p;
      now = f4 * now;
    }
    ops.emplace_back(now);
  }

  int Q;
  cin >> Q;
  rep(i, Q) {
    int a, b;
    cin >> a >> b;
    b--;
    Matrix<ll> pos = {{xy[b].first}, {xy[b].second}, {1}};
    auto ans = ops[a] * pos;
    ll x = ans[0][0], y = ans[1][0];
    cout << x << " " << y << "\n";
  }
}


//#include <atcoder/maxflow.hpp>
#include <memory>
#include <iostream>
#include <map>
#include <list>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>
#include <complex>
#include <thread>

#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s

typedef long long ll;

using namespace std;
//using namespace atcoder;

ll modd = 1000 * 1000 * 1000 + 7;


int main()   {

    ios_base::sync_with_stdio(false);

    cout.precision(17);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no

    auto start = chrono::steady_clock::now(); 

//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readint(x);
        cout << (x>=0 ? x : 0) << endl;
    }
//        auto stop = chrono::steady_clock::now(); 
//        auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start);
//        cout << "Duration: " << duration.count() << endl;
    return 0;
}

