#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__",", __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000
#define EPS 1e-8

// ???????°???°???????????????
inline double add(double a, double b){
  if(abs(a+b) < EPS*(abs(a) + abs(b))) return 0;
  return a+b;
}

struct Point{
  double x,y;
  Point() {}
  Point(double nx, double ny) : x(nx), y(ny) {}
  inline Point operator + (const Point p){ return Point(add(x, p.x), add(y, p.y)); }
  inline Point operator - (const Point p){ return Point(add(x,-p.x), add(y,-p.y)); }
  inline Point operator * (double d){ return Point(x*d, y*d); }
  inline double dot(const Point p){ return add(x * p.x, y*p.y); }  //??????
  inline double det(const Point p){ return add(x * p.y, -y*p.x); } //??????
  inline double dist(const Point p){ return sqrt((x-p.x)*(x-p.x) + (y-p.y)*(y-p.y)); }
  inline bool operator < (const Point p) const {
    if(x != p.x) return x < p.x;
    else return y < p.y;
  }
  inline bool operator == (const Point p) const {
    return (add(x, -p.x)==0) && (add(y, -p.y)==0);
  }
  friend ostream& operator<<(ostream& os, const Point& p) {
    os << "[" << p.x << "," << p.y << "]";
    return os;
  }
};

double norm(Point p) {return p.x*p.x+p.y*p.y;}
Point proj(Point a1, Point a2, Point p){
  return a1+(a2-a1) * ( (a2-a1).dot(p-a1)/norm(a2-a1) );
}

vector<Point> GrahamScan(vector<Point> points){
  int n = points.size();
  sort(all(points));
  int k=0;
  vector<Point> qs(2*n);
  for(int i=0; i<n; qs[k++] = points[i++]){
    while(k>1 && (qs[k-1] - qs[k-2]).det(points[i] - qs[k-1]) <= 0) k--;
  }
  for(int i=n-2,t=k; i>=0; qs[k++] = points[i--]){
    while(k>t && (qs[k-1] -qs[k-2]).det(points[i] - qs[k-1]) <= 0) k--;
  }
  qs.resize(k-1);
  return qs;
}

int main(){
  int n;
  cin>>n;
  const int dx[] = {-1,0,1,0}, dy[]={0,-1,0,1};
  vector<Point> vec;
  rep(x,2)rep(y,2) vec.pb(Point(x,y));
  rep(i,n-1){
    int p,d;
    cin>>p>>d;
    double bx = vec[p*4].x+dx[d], by = vec[p*4].y+dy[d];
    rep(x,2)rep(y,2) vec.pb(Point(bx+x, by+y));
  }

  vec = GrahamScan(vec);
  n = vec.size();

  int i=0,j=0,k=0,l=0;
  while(vec[i].y>vec[i+1].y) i = (i+1)%n;
  j = i;
  while(vec[j].x<vec[j+1].x) j = (j+1)%n;
  k = j;
  while(vec[k].y<vec[k+1].y) k = (k+1)%n;
  l = k;
  while(vec[l].x>vec[l+1].x) l = (l+1)%n;

  auto area = [&](int a, int b, int c, int d){
    Point p1 = proj(vec[a], vec[(a+1)%n], vec[b]);
    Point p2 = proj(vec[a], vec[(a+1)%n], vec[d]);
    double w = p1.dist(p2);
    Point p3 = proj(vec[a], vec[(a+1)%n], vec[c]);
    double h = vec[c].dist(p3);
//    dbg(a,b,c,d,vec, w*h);
    return w*h;
  };
//dbg(vec);
  double best = area(i,j,k,l);
  int si=i;
  int cnt = 0;
  while(si != i || cnt<n){
    i = (i+1)%n;
    if(i==j) j = (j+1)%n;

    while( (vec[(i+1)%n]-vec[i]).det(vec[(k+1)%n]-vec[k]) >= 0){
      k = (k+1)%n;
      if(k==l) l= (l+1)%n;
    }

    while( (vec[(i+1)%n]-vec[i]).dot(vec[j] - vec[(j-1+n)%n]) * (vec[(i+1)%n]-vec[i]).dot(vec[(j+1)%n] - vec[j]) > 0 ) j = (j+1)%n;
    while( (vec[(i+1)%n]-vec[i]).dot(vec[l] - vec[(l-1+n)%n]) * (vec[(i+1)%n]-vec[i]).dot(vec[(l+1)%n] - vec[l]) > 0 ) l =  (l+1)%n;

    best = min(best, area(i,j,k,l));
    cnt++;
  }

  printf("%.7f\n", best);

  return 0;
}

Measured memory_bytes: 15372