#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
using namespace std;

int n;
int top[100], bottom[100];
int dp[100][100];

int solve(int l, int r) {
    if (0 <= dp[l][r]) return dp[l][r];
    if (l == r) return 0;
    int ret = INT_MAX;
    for (int i=l+1; i<=r; ++i) {
        ret = min(ret, solve(l,i-1) + solve(i,r) + top[l] * bottom[i-1] * top[i] * bottom[r]);
    }
    return dp[l][r] = ret;
}

int main() {
    memset(dp, -1, sizeof dp);
    cin >> n;
    for (int i=0; i<n; ++i) {
        cin >> top[i] >> bottom[i];
    }
    cout << solve(0, n-1) << endl;
    return 0;
}