"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
class priorityQueue{
  constructor(){
    this.heap = [];
  }
  push(x){
    var h = this.heap, i = h.length++, j;
    while(i){
      j = i-1 >> 1;
      if(h[j][0] <= x[0])break;
      h[i] = h[j], i = j;
    }
    h[i] = x;
  }
  pop(){
    var h = this.heap, x = h.pop(), l = h.length;
    if(l === 0)return x;
    var r = h[0], i = 0, k = l >> 1, j;
    while (i < k) {
      j = i + i + 1;
      if(j < l-1 && h[j+1][0] < h[j][0])++j;
      if(x[0] <= h[j][0])break;
      h[i] = h[j], i = j;
    }
    h[i] = x;
    return r;
  }
  get size(){return this.heap.length;}
  get top(){return this.heap[0];}
}
class dijkstra{
  constructor(n){
    this.graph = Array(n).fill().map(a=>[]);
  }
  add(from,to,cost){
    this.graph[from].push({to:to,cost:cost});
  }
  solve(start,goal){
    const INF = 2e9;
    const g = this.graph, n = g.length;
    const cost = Array(n).fill(INF);
    const pq = new priorityQueue();
    cost[start] = 0;
    pq.push([0,start]);
    while(pq.size){
      var v = pq.pop()[1];
      if(v === goal)return cost[v];
      for(var i = 0; i < g[v].length; i++){
        var V = g[v][i].to;
        var c = cost[v] + g[v][i].cost;
        if(c < cost[V]){
          cost[V] = c;
          pq.push([c,V]);
        }
      }
    }
    return -1;
  }
}

console.log(main());
function main(){
  var xs = o.a();
  var ys = o.a();
  var xt = o.a();
  var yt = o.a();
  var n = o.a();
  var g = o.m(n);
  g.push([xs,ys,0],[xt,yt,0]);
  var di = new dijkstra(n+2);
  for(var i = 0; i < n+2; i++)for(var j = i+1; j < n+2; j++){
    var x = g[i][0]-g[j][0];
    var y = g[i][1]-g[j][1];
    var dist = Math.sqrt(x*x+y*y);
    dist -= g[i][2] + g[j][2];
    if(dist < 0)dist = 0;
    di.add(i,j,dist);
    di.add(j,i,dist);
  }
  return di.solve(n,n+1);
}