#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int n;
	while(cin>>n){
		int cost[100][100]={0},t[100],b[100];
		rep(i,n)cin>>t[i]>>b[i];
		rep(j,n)if(j)rep(i,n-j){
			int mn=1<<30,c;
			rep(k,j)if(mn>(c=cost[k][i]+cost[j-k-1][i+k+1]+t[i]*b[i+k]*t[i+k+1]*b[i+j]))mn=c;
			cost[j][i]=mn;
		}
		cout<<cost[n-1][0]<<endl;
	}
	return 0;
}