#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e10+1)
//#define INF (1LL<<59)


#define OUT 0
#define ON 1
#define IN 2
#define EPS (1e-10)
class P{                    //???
public:
	double x,y;
	
	P(double _x=0,double _y=0):x(_x),y(_y){};
	P operator + (const P &p     )const{ return P( x+p.x , y+p.y ); }  //??????
	P operator - (const P &p     )const{ return P( x-p.x , y-p.y ); }  //??????
	P operator * (const double k )const{ return P( x*k   , y*k    ); } //??????
	P operator / (const double k )const{ return P( x/k   , y/k    ); } //??????
	
	bool operator == (const P &p){ return ( fabs(x-p.x)<EPS && fabs(y-p.y)<EPS ); }
	bool operator < (const P &p) const{ return ( x!=p.x ? x<p.x:y<p.y ); }
	
	double norm(){ return x*x+y*y; }        //?????????
	double abs() { return sqrt(norm()); }   //??§??????
	void normalize() {double d = sqrt(x*x+y*y); x /= d; y /= d;}	//??£??????
};
struct C{P p;double r;};    //???
struct S{P p1,p2;};         //??????
typedef vector<P> Polygon;  //????§???¢
typedef P Vector;           //????????????
typedef S L;                //??´???

double norm (P p)               { return p.norm(); }
double abs  (P p)               { return p.abs(); }
double dot  (Vector a,Vector b) { return a.x*b.x+a.y*b.y; }
double cross(Vector a,Vector b) { return a.x*b.y-a.y*b.x; }
double sqDist(P a, P b)         {return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);}
double dist (P a, P b)          {return sqrt(sqDist(a,b));}
Vector vec(S a)                 {return P(a.p2.x-a.p1.x,a.p2.y-a.p1.y);}


//?????? verified AOJ0068,QUPC-G
//???????????§??????
bool cmp_x(const P& p, const P& q){
	if(p.x != q.x)return p.x<q.x;
	return p.y<q.y;
}

//??????????±???????
vector<P> convex_hull(vector<P> ps){
	int n = ps.size();
	sort(all(ps),cmp_x);
	int k=0;            //?????????????????°
	vector<P> qs(n*2);  //?§????????????????
	//?????´???????????????
	rep(i,n){
		while( k>1 && cross((qs[k-1]-qs[k-2]) , (ps[i]-qs[k-1]))<=0 ) k--;
		qs[k++]=ps[i];
	}
	//?????´???????????????
	for(int i=n-2, t=k;i>=0;i--){
		while( k>t && cross((qs[k-1]-qs[k-2]) , (ps[i]-qs[k-1]))<=0 ) k--;
		qs[k++]=ps[i];
	}
	qs.resize(k-1);
	return qs;
}



double solveLR(vector<P> ps,S l){
	double mini=INF;
	double maxi=-INF;
	
	rep(i,ps.size()){
		double res = dot(l.p2-l.p1,ps[i]-l.p1)/abs(l.p2-l.p1);
		mini = min(res,mini);
		maxi = max(res,maxi);
	}
	return maxi-mini;
}

double solveU(vector<P> ps,S l){
	double maxi = -INF;
	rep(i,ps.size()){
		double res = cross(l.p2-l.p1,ps[i]-l.p1)/abs(l.p2-l.p1);
		maxi = max(maxi,abs(res));
	}
	return maxi;
}


int main(){
	int n;
	cin>>n;
	
	vector<P> inp(n);
	inp[0] = P(0,0);
	for(int i=1;i<n;i++){
		int a,b;
		cin>>a>>b;
		if(b==0)		inp[i] = inp[a]+P(-1,0);
		else if(b==1)	inp[i] = inp[a]+P(0,-1);
		else if(b==2)	inp[i] = inp[a]+P(+1,0);
		else if(b==3)	inp[i] = inp[a]+P(0,+1);
	}
	set<P> ps;
	rep(i,n){
		ps.insert(inp[i]+P(0,0));
		ps.insert(inp[i]+P(1,0));
		ps.insert(inp[i]+P(0,1));
		ps.insert(inp[i]+P(1,1));
	}
	
	vector<P> arg;
	for(auto &elm:ps)arg.pb(elm);
	
	vector<P> points = convex_hull(arg);
	
	double ans = INF;
	
	rep(i,points.size()){
		S line = S{points[i],points[(i+1)%points.size()]};
		
		double LR = solveLR(points,line);
		double U  = solveU(points,line);
//		cout<<LR<<" "<<U<<endl;
		ans = min( ans , LR*U );
	}
	printf("%.10lf\n",ans);
}

Measured memory_bytes: 29504