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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define RALL(a)     (a).rbegin(),(a).rend()
#define PRINT(a)   cout << (a) << endl

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

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 (b<a) { a=b; return 1; } return 0; }

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

int main(){
  int n;
  cin >> n;
  vi a(n),b(n);
  REP(i,n)cin >> a[i] >> b[i];

  ll ans=LINF;
  REP(i,n)REP(j,n){
    if(i==j){
      chmin(ans, (ll)(a[i]+b[j]));
    }else{
      chmin(ans, (ll)max(a[i],b[j]));
    }
  }
  cout << ans << endl;
}


#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(int i=cc;i>=n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;
 
const vector<int> dx = {1, 0, -1,  0};
const vector<int> dy = {0, 1,  0, -1};
 
const vector<int> dx2 = {1, 1,  1, 0,  0, 0, -1, -1, -1};
const vector<int> dy2 = {1, 0, -1, 1, -1, 0,  1,  0, -1};
 
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;
const ll mod2 = 998244353;
 
const ll MAX = 1000000;
const int MOD = 1000000007;
const ll big = (1ll<<60);
 
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }

vector<vector<ll>>calc(vector<vector<ll>>a, vector<vector<ll>>b){
    vector<vector<ll>> c(3,vector<ll>(3));
    rep(i2, 0, 3){
        rep(j2, 0, 3){
            rep(k2, 0, 3){
                c[i2][j2] += a[i2][k2]*b[k2][j2];
            }
        }
    }
    return c;
}

int main(){
    int n;
    cin >> n;
    vector<ll>x(n),y(n);
    rep(i, 0, n)cin >> x[i] >> y[i];
    int m;
    cin >> m;
    vector<pll>op(m);
    vector<vector<vector<ll>>>matrix(m+1,vector<vector<ll>>(3,vector<ll>(3)))
    ,accum(m+1,vector<vector<ll>>(3,vector<ll>(3)));
    rep(i, 0, m){
        cin >> op[i].first;
        vector<vector<ll>>temp(3,vector<ll>(3));
        if(op[i].first==3||op[i].first==4)cin >> op[i].second;
        if(op[i].first==1){
            temp[0][1] = 1;
            temp[1][0] = -1;
        }else if(op[i].first==2){
            temp[0][1] = -1;
            temp[1][0] = 1;
        }else if(op[i].first==3){
            temp[0][0] = -1;
            temp[0][2] = 2*op[i].second;
            temp[1][1] = 1;
        }else{
            temp[0][0] = 1;
            temp[1][2] = 2*op[i].second;
            temp[1][1] = -1;
        }
        temp[2][2] = 1;
        matrix[i+1] = temp;
    }
    rep(i, 1, m+1){
        if(i==1)accum[i] = matrix[i];
        else{
            accum[i] = calc(matrix[i],accum[i-1]);
        }
    }
    int q;
    cin >> q;
    vector<pll>query(q);
    rep(i, 0, q)cin >> query[i].first >> query[i].second;
    rep(i, 0, q){
        if(query[i].first==0){
            cout << x[query[i].second-1] << " " << y[query[i].second-1] << endl;
        }else{
            ll ansx, ansy;
            ansx = accum[query[i].first][0][0]*x[query[i].second-1]+
            accum[query[i].first][0][1]*y[query[i].second-1]+
            accum[query[i].first][0][2]*1;

            ansy = accum[query[i].first][1][0]*x[query[i].second-1]+
            accum[query[i].first][1][1]*y[query[i].second-1]+
            accum[query[i].first][1][2]*1;

            cout << ansx << " " << ansy << endl;
        }
    }
}