#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<pdd> vpdd;
typedef vector<vd> vvd;
#define yn(ans) printf("%s\n", (ans)?"Yes":"No");
#define YN(ans) printf("%s\n", (ans)?"YES":"NO");
    template<class T> bool chmax(T &a, T b) {
	if (a >= b) return false;
	a = b; return true;
}
template<class T> bool chmin(T &a, T b) {
	if (a <= b) return false;
	a = b; return true;
}
#define FOR(i, s, e, t) for ((i) = (s); (i) < (e); (i) += (t)) 
#define REP(i, e) for (int i = 0; i < (e); ++i) 
#define REP1(i, s, e) for (int i = (s); i < (e); ++i)
#define RREP(i, e) for (int i = (e); i >= 0; --i)
#define RREP1(i, e, s) for (int i = (e); i >= (s); --i)
#define all(v) v.begin(), v.end()
#define pb push_back
#define qb pop_back
#define pf push_front
#define qf pop_front
#define maxe max_element
#define mine min_element
ll inf = 1e18;
#define DEBUG printf("%d\n", __LINE__); fflush(stdout);
template<class T> void print(vector<T> &v, bool withSize = false) {
	if (withSize) cout << v.size() << endl;
	REP(i, v.size()) cout << v[i] << " "; 
	cout << endl;
}
mt19937_64 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());

int __FAST_IO__ = []() {
	std::ios::sync_with_stdio(0);
	std::cin.tie(0);
	std::cout.tie(0);
	return 0;
}();

#define TESTS int t; cin >> t; while (t--)
#define TEST 
int main() {
    TEST {
        int N, K;
        cin >> N >> K;
        vi x(N + 1, 0), y(N + 1, 0);
        REP(i, N) cin >> x[i] >> y[i];
        
        auto dis = [&](int a, int b) {
            return sqrt((double)(x[a] - x[b]) * (x[a] - x[b]) + (double)(y[a] - y[b]) * (y[a] - y[b]));  
        };
        
        vector<vvd> dp(1 << N, vvd(N + 1, vd(K + 1, 1e18)));
        dp[0][N][K] = 0;
        REP(i, 1 << N) {
            if (i == 0) {
                REP(j, N) {
                    dp[1 << j][j][K - 1] = dis(j, N);    
                }
            } else {
                REP(j, N + 1) {
                    if (j != N && !(i >> j & 1)) continue;
                    REP(k, K + 1) {
                        REP(l, N + 1) {
                            if (k == 0 && l != N) continue;
                            if (l != N && (i >> l & 1)) continue;
                            chmin(dp[i | (l == N ? 0 : (1 << l))][l][l == N ? K : k - 1], dp[i][j][k] + dis(j, l));
                        }
                    }
                }
            }
        }
        
        double ans = 1e18;
        REP(i, N) REP(j, K + 1) chmin(ans, dp[(1 << N) - 1][i][j] + dis(i, N));
        printf("%.12lf\n", ans);
    }
    
    return 0;
}