/*
Jackson Simoneau
SI@UCF 2026 - Intro to Competitive Programming
Final Contest

Solution to Collecting Beepers: https://open.kattis.com/problems/beepers
*/

#include <bits/stdc++.h>
using namespace std;

int main() {
    //Process test cases
    int t; cin >> t;
    while(t--) {
        //Ignore the size of the grid
        int x, y;
        cin >> x >> y >> x >> y;
        int n; cin >> n;
        vector<pair<int, int>> b(n);
        for(int i = 0; i < n; i++) {
            cin >> b[i].first >> b[i].second;
        }

        //Find the distance between every pair of beepers and the starting position
        vector<vector<int>> dist(n+1, vector<int>(n+1));
        for(int i = 0; i <= n; i++) {
            for(int j = 0; j <= n; j++) {
                //Find the location of the two points
                int x1, y1, x2, y2;
                if(i == n) {
                    x1 = x, y1 = y;
                } else {
                    x1 = b[i].first, y1 = b[i].second;
                }
                if(j == n) {
                    x2 = x, y2 = y;
                } else {
                    x2 = b[j].first, y2 = b[j].second;
                }

                //Compute the distance between these points
                dist[i][j] = abs(x1-x2) + abs(y1-y2);
            }
        }

        vector<int> perm(n);
        for(int i = 0; i < n; i++) perm[i] = i;
        
        int res = 1000000;
        do {
            //Compute the total number of moves to collect the beepers in this order
            //and return to the starting position
            int moves = dist[n][perm[0]];
            for(int i = 1; i < n; i++) {
                moves += dist[perm[i-1]][perm[i]];
            }
            moves += dist[perm[n-1]][n];

            //Keep the best answer over all permutations
            res = min(res, moves);
        } while(next_permutation(perm.begin(), perm.end()));

        //Display the answer
        cout << res << endl;
    }
}