#include <cmath>
#include <stack>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>

using namespace std;

typedef long long ll;

#ifdef iq
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

const int N = 2e5 + 20;
const ll inf = (ll) (1e18) + 7;

int rx[N], ry[N];

ll dist(int i, int j) {
  return abs(rx[i] - rx[j]) + abs(ry[i] - ry[j]);
}
                         
namespace Solver {
    struct PermutationIntervalChecker {
        std::vector<int> lg2;
        std::vector<std::vector<int>> min, max;
        int n;
    public:
        explicit PermutationIntervalChecker(const std::vector<int> &a) {
            n = a.size();
 
            lg2.resize(n + 1);
            for(int i = 2; i <= n; i++) lg2[i] = lg2[i>>1] + 1;
 
            min.resize(lg2[n]+1, std::vector<int>(n));
            max.resize(lg2[n]+1, std::vector<int>(n));
            min[0] = a;
            max[0] = a;
            for(int k = 0; k < lg2[n]; k++) {
                for(int i = 0; i + (2 << k) - 1 < n; i++) {
                    min[k + 1][i] = std::min(min[k][i], min[k][i + (1<<k)]);
                    max[k + 1][i] = std::max(max[k][i], max[k][i + (1<<k)]);
                }
            }
        }
 
        bool is_interesting (int l, int r) {
            int k = lg2[r - l + 1];
            return std::max(max[k][l], max[k][r - (1<<k) + 1]) - std::min(min[k][l], min[k][r - (1<<k) + 1]) == r - l;
        }
    };
 
    class LazySegmentTree {
        typedef int T1; // Change this to what you need
        typedef int T2; // Change this to what you need
        T1 id = 0, initval = 0;
        T2 unused = 0;
        T1 combine(T1 a, T1 b){ return std::min(a, b); }
        T2 combineL(T2 a, T2 b){ return a + b; }
        void unlazy(int i, int nl, int nr){ arr[i] += lazy[i]; }
 
        int n; std::vector<T1> arr; std::vector<T2> lazy;
        void propagate(int x, int nl, int nr){
            if(lazy[x] == unused) return;
            if(x < n){
                lazy[x*2] = combineL(lazy[x*2], lazy[x]);
                lazy[x*2+1] = combineL(lazy[x*2+1], lazy[x]);
            }
            unlazy(x, nl, nr);
            lazy[x] = unused;
        }
        void update(int l,int r,T2 val,int x,int nl,int nr){
            propagate(x, nl, nr);
            if(r < nl || nr < l) return;
            if(l <= nl && nr <= r){
                lazy[x] = combineL(lazy[x], val);
                propagate(x, nl, nr);
                return;
            }
            int mid = (nl + nr) / 2;
            update(l,r,val,x*2,nl,mid);
            update(l,r,val,x*2+1,mid+1,nr);
            arr[x] = combine(arr[x*2], arr[x*2+1]);
        }
        T1 query(int l,int r,int x,int nl,int nr){
            propagate(x, nl, nr);
            if(r < nl || nr < l) return id;
            if(l <= nl && nr <= r) return arr[x];
            int mid = (nl + nr) / 2;
            return combine(query(l,r,x*2,nl,mid),
                           query(l,r,x*2+1,mid+1,nr));
        }
        int find_zero(int x, int nl, int nr) {
            if(nl == nr) return nl;
            propagate(x, nl, nr);
            int mid = (nl + nr) / 2;
            if(arr[x*2] + lazy[x*2] == 0) {
                return find_zero(x*2, nl, mid);
            }else {
                return find_zero(x*2+1, mid+1, nr);
            }
 
        }
    public:
        explicit LazySegmentTree(int sz) {
            n = 1;
            while(n < sz) n *= 2;
            arr.resize(n*2, initval); lazy.resize(n*2, unused);
        }
        void update(int l,int r,T2 val)
        {update(l,r,val,1,0,n-1);}
        int find_zero() {
            return find_zero(1, 0, n-1);
        }
    };
 
    enum NODE_TYPE { ANALYTIC, CONVERGE };
    struct Node {
        int l, r, m;
        NODE_TYPE type = ANALYTIC;
        std::vector<std::reference_wrapper<Node>> children;
    };
 
    class PermutationTree {
        std::vector<Node> tree;
        std::vector<int> id;
        int n;
        Node root;
 
        void dfs (Node &node, ll left, ll right, vector <ll> &ans, int x, int y) {
          if (node.l == node.r) {
            ans[node.l] = min(left, right) - (y - x);
            return;
          } else {
            if (node.type != CONVERGE) {
              for (Node &child : node.children) {
                dfs(child, 0, 0, ans, child.l, child.r);
              }
            } else {
              vector <pair <int, int> > t;
              for (Node &child : node.children) {
                t.push_back({child.l, child.r});
              }
              vector <int> vl(t.size()), vr(t.size());
              for (int i = 0; i < (int) t.size(); i++) {
                if (i && t[i - 1].first == t[i - 1].second) {
                  vl[i] = vl[i - 1];
                } else {
                  vl[i] = i;
                }
              }
              for (int i= (int) t.size() - 1; i >= 0; i--) {
                if (i + 1 < (int) t.size() && t[i + 1].first == t[i + 1].second) {
                  vr[i] = vr[i + 1];
                } else {
                  vr[i] = i;
                }
              }
              for (int i = 0; i < (int) t.size(); i++) {
                int l = vl[i], r = vr[i];
                bool complete = (l == 0 && r == (int) t.size() - 1);
                if (!left && !right) complete = false;
                ll left_ans = inf, right_ans = inf;
                {
                  {
                    ll val = dist(t[l].first, t[i].first) + ((r != i) || complete) * dist(t[l].first, t[r].second);
                    if (complete) val += right;
                    left_ans = min(left_ans, val);
                  }
                  {
                    ll val = dist(t[r].second, t[i].first) + ((l != i) || complete) * dist(t[l].first, t[r].second);
                    if (complete) val += left;
                    left_ans = min(left_ans, val);
                  }
                }
                {
                  {
                    ll val = dist(t[l].first, t[i].second) + ((r != i) || complete) * dist(t[l].first, t[r].second);
                    if (complete) val += right;
                    right_ans = min(right_ans, val);
                  }
                  {
                    ll val = dist(t[r].second, t[i].second) + ((l != i) || complete) * dist(t[l].first, t[r].second);
                    if (complete) val += left;
                    right_ans = min(right_ans, val);
                  }
                }
                if (complete) {
                  if (r == i) {
                    left_ans = min(left_ans, left + dist(t[l].first, t[i].first));
                    right_ans = min(right_ans, left + dist(t[l].first, t[i].second));
                  }
                  if (l == i) {
                    left_ans = min(left_ans, right + dist(t[i].first, t[r].second));
                    right_ans = min(right_ans, right + dist(t[i].second, t[r].second));
                  }
                }
                if (complete)
                  dfs(node.children[i], left_ans, right_ans, ans, x, y);
                else
                  dfs(node.children[i], left_ans, right_ans, ans, t[l].first, t[r].second);
              }
            }
          }
        }
        /*
            long long ret = 0;
 
            for(Node &child : node.children) {
                ret += dfs(child, x);
            }
 
            if(node.type == CONVERGE) {
                struct State { int cl, cr, len; };
                std::vector<State> states;
                int cl = 0, cr = node.children.size() - 1;
                for(Node &child : node.children) {
                    states.push_back({ cl, cr, child.r - child.l + 1 });
                    cl += 1;
                    cr -= 1;
                }
 
                for(int i = 0, j = 0, len = 0, sumcl = 0; j < states.size(); j++) {
                    len += states[j].len;
                    while(i <= j && len >= x) {
                        len -= states[i].len;
                        (sumcl += states[i].cl) %= MOD;
                        i++;
                    }
                    ret += 1ll * sumcl * states[j].cr % MOD;
                }
            }
            ret %= MOD;
            return ret;
        }
        */
    public:
        explicit PermutationTree (const std::vector<int> &p) {
            n = p.size();
 
            PermutationIntervalChecker checker(p);
            LazySegmentTree seg(n); // For each j, contains {max(p[j..i]) - min(p[j..i])} - {i-j}
 
            std::stack<int> stkMin, stkMax;
            std::stack<std::reference_wrapper<Node>> stkPath;
 
            tree.reserve(n*2);
            id.resize(n);
            for(int i = 0; i < n; i++) {
                auto processHistogram = [&](std::stack<int> &stk, int coef) {
                    while(!stk.empty() && (p[i] - p[stk.top()]) * coef > 0) {
                        int r = stk.top(); stk.pop();
                        int l = (stk.empty() ? -1 : stk.top()) + 1;
                        seg.update(l, r, -coef * p[r]);
                    }
                    int l = (stk.empty() ? -1 : stk.top()) + 1;
                    seg.update(l, i, coef * p[i]);
                    stk.push(i);
                };
                processHistogram(stkMax, +1);
                processHistogram(stkMin, -1);
 
                id[i] = tree.size();
                tree.push_back({i, i});
 
                int le = seg.find_zero();
                std::reference_wrapper<Node> cur = tree.back();
 
                while(!stkPath.empty() && stkPath.top().get().l >= le) {
                    Node &node = stkPath.top();
                    if(node.l < le) break;
 
                    if(node.type == CONVERGE && checker.is_interesting(node.m, i)) {
                        node.r = i;
                        node.children.push_back(cur);
                        cur = node;
                        stkPath.pop();
                    }else if(checker.is_interesting(node.l, i)) {
                        tree.push_back({node.l, i, cur.get().l, CONVERGE, {node, cur}});
                        stkPath.pop();
                        cur = tree.back();
                    }else {
                        tree.push_back({});
                        Node &new_node = tree.back();
                        new_node.children.push_back(cur);
                        do {
                            new_node.children.push_back(stkPath.top());
                            stkPath.pop();
                        }while(!stkPath.empty() && !checker.is_interesting(stkPath.top().get().l, i));
 
                        assert(!stkPath.empty());
                        new_node.l = stkPath.top().get().l;
                        new_node.r = i;
                        new_node.type = ANALYTIC;
                        new_node.children.push_back(stkPath.top());
                        stkPath.pop();
                        cur = new_node;
                    }
                }
 
                stkPath.push(cur);
                seg.update(0, i, -1);
            }
            while(stkPath.size() > 1) stkPath.pop();
            assert(stkPath.size() == 1);
            root = stkPath.top();
        }
 
        vector <ll> solve() {
          vector <ll> ans(n);
          dfs(root, 0, 0, ans, 0, n - 1);
          return ans;
        }
    };
 
    vector <ll> solve (const std::vector<int>& p) {
        PermutationTree tree(p);
        return tree.solve();
    }
};

int main() {
#ifdef iq
  freopen("a.in", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector <pair <int, int> > e;
  vector <int> ord;
  vector <int> x(n), y(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    e.push_back({x[i], i});
    ord.push_back(y[i]);
  }
  sort(ord.begin(), ord.end());
  sort(e.begin(), e.end());
  vector <int> p(n);
  for (int i= 0; i < n; i++) {
    rx[i] = e[i].first;
    ry[i] = y[e[i].second];
    p[i] = lower_bound(ord.begin(), ord.end(), y[e[i].second]) - ord.begin();
  }
  auto s = Solver::solve(p);
  vector <ll> ret(n);
  for (int i = 0; i < n; i++) {
    ret[e[i].second] = s[i];
  }
  for (int i = 0; i < n; i++) cout << ret[i] << '\n';
}


Measured memory_bytes: 105124