// 6/17/2026
// Solution to Kattis Problem: Collecting Beepers
// https://open.kattis.com/problems/beepers

using namespace std;
#include <bits/stdc++.h>

int go(vector<int>& perm, vector<bool>& used, int k, vector<pair<int,int>>& pts, pair<int,int>& me);
int eval(vector<int>& perm, vector<pair<int,int>>& pts, pair<int,int>& me);

int main() {

    // Process cases.
    int nC;
    cin >> nC;
    for (int loop=0; loop<nC; loop++) {

        // Read in where I am and the # of points.
        pair<int,int> me;
        int n, dummy;
        cin >> dummy >> dummy;
        cin >> me.first >> me.second;
        cin >> n;
        vector<pair<int,int>> pts(n);

        // Read in the points.
        for (int i=0; i<n; i++)
            cin >> pts[i].first >> pts[i].second;

        // Run it!
        vector<int> perm(n);
        vector<bool> used(n, false);
        cout << go(perm, used, 0, pts, me) << endl;
    }

    return 0;
}

int go(vector<int>& perm, vector<bool>& used, int k, vector<pair<int,int>>& pts, pair<int,int>& me) {

    // We're done, return the answer.
    if (k == perm.size())
        return eval(perm, pts, me);

    // Easily big enough.
    int res = 10000000;

    // Try each item in slot k.
    for (int i=0; i<perm.size(); i++) {
        if (used[i]) continue;

        // Place i in slot k.
        used[i] = true;
        perm[k] = i;
        int tmp = go(perm, used, k+1, pts, me);
        res = min(res, tmp);

        // Undo.
        used[i] = false;
    }

    // Ta da!
    return res;
}

// Returns the cost of this permutation of visits.
int eval(vector<int>& perm, vector<pair<int,int>>& pts, pair<int,int>& me) {

    // Add in all the internal paths.
    int n = perm.size();
    int res = 0;
    for (int i=0; i<n-1; i++) {
        int u = perm[i];
        int v = perm[i+1];
        res += (abs(pts[u].first - pts[v].first) + abs(pts[u].second - pts[v].second));
    }

    // First path.
    res += (abs(me.first - pts[perm[0]].first) + abs(me.second - pts[perm[0]].second));

    // Last path.
    res += (abs(me.first - pts[perm[n-1]].first) + abs(me.second - pts[perm[n-1]].second));

    // Finally!
    return res;
}
