#include <bits/stdc++.h>

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  vector<LL> x, y;
  LL N = (1ll << 58);
  vector<vector<vector<int>>> dp_;
  Solver(LL n) : n(n), x(n), y(n), dp_(61, vector<vector<int>>(3, vector<int>(2))){};
  bool isOdd(LL a, LL b) {
    if (a < b) return false;
    if (b < 0) return false;
    return (a - b) == (a ^ b);
  }
  int coeffMod2(LL X) {
    int ret = 0;
    for (int i = 0; i < n; ++i) {
      ret += isOdd(y[i] + N, X - x[i]);
    }
    DBG(X, ret % 2)
    return ret % 2;
  }

  vector<int> countBlackMod2(LL h, LL w) {
    //(0,0)の黒い点を直線y=-h上に移したとき、{(x,-h) | x∈[0,w], x=c (mod 3) } となる黒い点の個数
    if (w < 0) return {0, 0, 0};
    w = min(w, h);
    //dp[i][j][k] : 上からi桁がmod 3でjに等しい数の個数　k=1ならばw以下であることが確定
    auto dp = [&](int a, int b, int c) -> int& { return dp_[a + 1][b][c]; };
    for (int i = 0; i < 61; ++i) {
      for (int j = 0; j < 3; ++j) {
        for (int k = 0; k < 2; ++k) {
          dp_[i][j][k] = 0;
        }
      }
    }
    dp(-1, 0, 0) = 1;
    for (int i = 0; i < 60; ++i) {
      if ((w >> (59 - i)) & 1) {
        for (int j = 0; j < 3; ++j) {
          if ((h >> (59 - i)) & 1) dp(i, (j + 1 + (59 - i) % 2) % 3, 0) += dp(i - 1, j, 0);
          dp(i, j, 1) += dp(i - 1, j, 0);
          if ((h >> (59 - i)) & 1) dp(i, (j + 1 + (59 - i) % 2) % 3, 1) += dp(i - 1, j, 1);
          dp(i, j, 1) += dp(i - 1, j, 1);
        }

      } else {
        for (int j = 0; j < 3; ++j) {
          //dp(i, (j + 1 + (59 - i) % 2) % 3, 0) += dp(i - 1, j, 0);
          dp(i, j, 0) += dp(i - 1, j, 0);
          if ((h >> (59 - i)) & 1) dp(i, (j + 1 + (59 - i) % 2) % 3, 1) += dp(i - 1, j, 1);
          dp(i, j, 1) += dp(i - 1, j, 1);
        }
      }
      for (int j = 0; j < 3; ++j) {
        for (int k = 0; k < 2; ++k) {
          dp(i, j, k) &= 1;
        }
      }
    }
    vector<int> ret(3);
    for (int i = 0; i < 3; ++i) {
      ret[i] = dp(59, i, 0) + dp(59, i, 1);
    }
    return ret;
  }

  int countBrackInRange(LL a, LL b, int c) {
    DBG(a, b, c)
    //{(x,-h) | x∈[a,b-1], x=c (mod 3) } となる黒い点の個数(mod 2)
    int ret = 0;
    for (int i = 0; i < n; ++i) {
      ret += countBlackMod2(y[i] + N, b - 1 - x[i])[((c - x[i]) % 3 + 3) % 3];
    }
    DBG(ret)
    for (int i = 0; i < n; ++i) {
      ret -= countBlackMod2(y[i] + N, a - 1 - x[i])[((c - x[i]) % 3 + 3) % 3];
    }
    DBG(ret)
    ret = ret & 1;
    return ret;
  }

  void solve() {
    for (int i = 0; i < n; ++i) {
      cin >> x[i] >> y[i];
    }
    vector<int> sum(3);
    for (int j = 0; j < n; ++j) {
      auto res = countBlackMod2(y[j] + N, y[j] + N);
      DBG(res)
      for (int i = 0; i < 3; ++i) {
        sum[((x[j] + i) % 3 + 3) % 3] += res[i];
      }
    }

    //個数が奇数になるグループを探す
    int r;
    for (int i = 0; i < 3; ++i) {
      if (sum[i] % 2) {
        r = i;
        break;
      }
    }
    DBG(r, sum)
    //二分探索
    //[lb,ub)に黒い点が奇数個あるようにする
    LL lb = -(1ll << 57), ub = (1ll << 59);
    while (ub - lb > 1) {
      DBG(lb, ub, N - 1)
      LL mid = (lb + ub) / 2;
      if (countBrackInRange(lb, mid, r) % 2) {
        ub = mid;
      } else {
        lb = mid;
      }
    }

    //黒い点を1つ見つけた
    LL ny = -N, nx = lb;
    DBG(nx, ny + N)
    LL ansl = nx, ansr = nx;
    DBG(coeffMod2(ansl))
    //y=-N上でx座標を動かして、y=-N上で最も左・最も右の黒い点を探す
    while (true) {
      bool fin = true;
      for (int i = 60 - 1; i >= 0; --i) {
        if (coeffMod2(ansl - (1ll << i))) {
          fin = false;
          ansl -= (1ll << i);
          break;
        }
      }
      DBG(ansl, fin)
      if (fin) break;
    }
    while (true) {
      bool fin = true;
      for (int i = 60 - 1; i >= 0; --i) {
        if (coeffMod2(ansr + (1ll << i))) {
          fin = false;
          ansr += (1ll << i);
          break;
        }
      }
      DBG(ansr)
      if (fin) break;
    }

    cout << ansl << ' ' << -N + (ansr - ansl) << endl;
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 384