#include <bits/stdc++.h>
using namespace std;

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

template <typename F>
class
#if defined(__has_cpp_attribute) && __has_cpp_attribute(nodiscard)
  [[nodiscard]]
#endif  // defined(__has_cpp_attribute) && __has_cpp_attribute(nodiscard)
FixPoint final : private F
{
public:
  template <typename G>
  explicit constexpr FixPoint(G&& g) noexcept
    : F{std::forward<G>(g)}
  {}

  template <typename... Args>
  constexpr decltype(auto)
  operator()(Args&&... args) const
#if !defined(__GNUC__) || defined(__clang__) || __GNUC__ >= 9
  noexcept(noexcept(F::operator()(std::declval<FixPoint>(), std::declval<Args>()...)))
#endif  // !defined(__GNUC__) || defined(__clang__) || __GNUC__ >= 9
  {
    return F::operator()(*this, std::forward<Args>(args)...);
  }
};  // class FixPoint


#if defined(__cpp_deduction_guides)
template <typename F>
FixPoint(F&&)
  -> FixPoint<std::decay_t<F>>;
#endif  // defined(__cpp_deduction_guides)


namespace
{
  template <typename F>
#if !defined(__has_cpp_attribute) || !__has_cpp_attribute(nodiscard)
  #  if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 4)
__attribute__((warn_unused_result))
#  elif defined(_MSC_VER) && _MSC_VER >= 1700 && defined(_Check_return_)
_Check_return_
#  endif  // defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 4)
#endif  // !defined(__has_cpp_attribute) || !__has_cpp_attribute(nodiscard)
  inline constexpr decltype(auto)
  makeFixPoint(F&& f) noexcept
  {
    return FixPoint<std::decay_t<F>>{std::forward<std::decay_t<F>>(f)};
  }
}  // namespace


int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N;
	cin>> N;
	vector<pair<int, string>> mon(N);
	REP(i, N) {
	  cin >> mon[i].sc >> mon[i].fs;
	}
	sort(all(mon), greater<>());
	cout << mon[1].sc << endl;
}

#include <bits/stdc++.h>
#include<bits/extc++.h>

using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int N = (int)2e5 + 50;

int n, m, q;
struct P {
    ll x, y;
} p[N], res[N];

struct Op {
    int tp, p;
} ops[N];
vector<pii> qrs[N];

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

    cin >> n;
    rep(i, 0, n) cin >> p[i].x >> p[i].y;
    cin >> m;
    rep(i, 0, m) {
        cin >> ops[i].tp;
        if(ops[i].tp >= 3) cin >> ops[i].p;
    }
    cin >> q;
    rep(i, 0, q) {
        int a, b; cin >> a >> b; b--;
        qrs[a].push_back({b, i});
    }
    ll c_x = 0, dx_x = 1, dy_x = 0;
    ll c_y = 0, dx_y = 0, dy_y = 1;
    rep(i, 0, m + 1) {
        for(auto pr : qrs[i]) {
            int id = pr.first;
            res[pr.second] = {c_x + dx_x * p[id].x + dy_x * p[id].y, c_y + dx_y * p[id].x + dy_y * p[id].y};
        }
        if(ops[i].tp == 1) {
            tie(c_x, dx_x, dy_x, c_y, dx_y, dy_y) =
                    make_tuple(c_y, dx_y, dy_y, -c_x, -dx_x, -dy_x);
        } else if(ops[i].tp == 2) {
            tie(c_x, dx_x, dy_x, c_y, dx_y, dy_y) =
                    make_tuple(-c_y, -dx_y, -dy_y, c_x, dx_x, dy_x);
        } else if(ops[i].tp == 3) {
            tie(c_x, dx_x, dy_x, c_y, dx_y, dy_y) =
                    make_tuple(2 * ops[i].p - c_x, -dx_x, -dy_x, c_y, dx_y, dy_y);
        } else {
            tie(c_x, dx_x, dy_x, c_y, dx_y, dy_y) =
                    make_tuple(c_x, dx_x, dy_x, 2 * ops[i].p - c_y, -dx_y, -dy_y);
        }
    }
    rep(i, 0, q) cout << res[i].x << " " << res[i].y << "\n";
}