// #ifdef ONLINE_JUDGE
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
// #endif
#include "bits/stdc++.h"
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fill(arr,val) memset(arr,val,sizeof(arr))
#define FOR(i, a, b) for(__typeof(b) i = a, _b = b; i <= _b; ++i)
#define FORD(i, a, b) for(__typeof(a) i = a, _b = b; i >= _b; --i)
#define ALL(a) (a).begin(), (a).end()
#define YES cout << "YES\n"
#define NO cout << "NO\n"
#define ll long long
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define ii pair<int,int>
#define iii pair<int,pair<int,int>>
#define dq deque<int>
#define nend '\n'
using namespace std;
const ll inf = 1e18;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,1,0,-1};
const int MOD = 1e9 + 7;
const ll hashi = 2e9 + 11;
void init_code() {
fast;
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
const int N=10, S=59049;
int n;
double px[2*N], py[2*N];
double dp[S][2*N];
int pw3[N+1];
double dist(double x1, double y1, double x2, double y2) { return hypot(x1-x2, y1-y2); }
/// 0: not picked up
/// 1: on the scooter
/// 2: delivered
// dp[0..2][p] = shortest path from home that reaches this state, standing at point p
void solve() {
cin >> n;
FOR(i,0,n-1) cin >> px[2*i] >> py[2*i] >> px[2*i+1] >> py[2*i+1];
pw3[0]=1;
FOR(i,1,n) pw3[i]=pw3[i-1]*3;
int full=pw3[n];
FOR(s,0,full-1) FOR(p,0,2*n-1) dp[s][p]=1e30;
FOR(i,0,n-1) dp[pw3[i]][2*i] = dist(0,0,px[2*i],py[2*i]);
FOR(s,1,full-1) FOR(p,0,2*n-1) {
double cur=dp[s][p];
if (cur>=1e12) continue;
FOR(i,0,n-1) {
int st=s/pw3[i]%3;
if (st==2) continue;
/// st 1 then pick up
/// st 2 then deliver
int q=2*i+st;
double nd=cur+dist(px[p],py[p],px[q],py[q]);
double& t=dp[s+pw3[i]][q];
if (nd<t) t=nd;
int q=2*i+st;
}
}
}
int done=full-1;
double ans=1e30;
FOR(p,0,2*n-1) ans=min(ans, dp[done][p]+dist(px[p],py[p],0,0));
cout << fixed << setprecision(10) << ans << nend;
}
int main() {
init_code();
int t = 1;
// cin >> t;
while (t--) {
solve();
}
return 0;
}