#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;

int dp[100][100], a[100], b[100];
int main() {
	int n; scanf("%d", &n);
	rep(i, n)scanf("%d%d", &a[i], &b[i]);
	fill(dp[0], dp[n], INT_MAX);
	rep(i, n)dp[i][i] = 0;
	for (int i = 1; i < n; i++)rep(j, n - i + 1) {
		if (dp[j][j + i - 1] == INT_MAX)continue;
		for (int k = 0; k < j; k++) {
			if (dp[k][j - 1] == INT_MAX)continue;
			dp[k][j + i - 1] = min(dp[k][j + i - 1], dp[k][j - 1] + dp[j][j + i - 1] + a[k] * b[j - 1] * a[j] * b[j + i - 1]);
		}
		for (int k = j + i; k < n; k++) {
			if (dp[j + i][k] == INT_MAX)continue;
			dp[j][k] = min(dp[j][k], dp[j][j + i - 1] + dp[j + i][k] + a[j] * b[j + i - 1] * a[j + i] * b[k]);
		}
	}
	printf("%d\n", dp[0][n - 1]);
}