#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;

const int SIZE = 100;

int main()
{
	int costs[ SIZE ][ SIZE ];
	int n;

	while( cin >> n ){
		for( int i = 0; i < n; ++i ){
			for( int j = 0; j < n; ++j ){
				costs[ i ][ j ] = 0x7fffffff;
			}
		}
		for( int i = 0; i < n; ++i ){
			costs[ i ][ i ] = 0;
		}
		vector< pair< int, int > > decks;
		for( int i = 0; i < n; ++i ){
			int f, b;
			cin >> f >> b;
			decks.push_back( make_pair( f, b ) );
		}
		/*
		for( int s = 0; s < n - 1; ++s ){
			int e = s + 1;
			costs[ s ][ e ] = decks[ s ].first * decks[ s ].second * decks[ e ].first * decks[ e ].second;
		}
		*/
		for( int span = 1; span < n; ++span ){
			for( int s = 0; s < n - span; ++s ){
				int e = s + span;
				for( int k = s; k < e; ++k ){
					costs[ s ][ e ] = min( costs[ s ][ e ], costs[ s ][ k ] + costs[ k + 1 ][ e ] + decks[ s ].first * decks[ k ].second * decks[ k + 1 ].first * decks[ e ].second );
				}
			}
		}
		cout << costs[ 0 ][ n - 1 ] << endl;
	}

	return 0;
}