Problem: On the xy-plane, Snuke is going to travel from the point (x_s, y_s) to the point (x_t, y_t). He can move in arbitrary directions with speed 1. Here, we will consider him as a point without size.

There are N circular barriers deployed on the plane. The center and the radius of the i-th barrier are (x_i, y_i) and r_i, respectively. The barriers may overlap or contain each other.

A point on the plane is exposed to cosmic rays if the point is not within any of the barriers.

Snuke wants to avoid exposure to cosmic rays as much as possible during the travel. Find the minimum possible duration of time he is exposed to cosmic rays during the travel.

Constraints

* All input values are integers.
* -10^9 ≤ x_s, y_s, x_t, y_t ≤ 10^9
* (x_s, y_s) ≠ (x_t, y_t)
* 1≤N≤1,000
* -10^9 ≤ x_i, y_i ≤ 10^9
* 1 ≤ r_i ≤ 10^9

Input

The input is given from Standard Input in the following format:


x_s y_s x_t y_t
N
x_1 y_1 r_1
x_2 y_2 r_2
:
x_N y_N r_N


Output

Print the minimum possible duration of time Snuke is exposed to cosmic rays during the travel. The output is considered correct if the absolute or relative error is at most 10^{-9}.

Examples

Input

-2 -2 2 2
1
0 0 1


Output

3.6568542495


Input

-2 0 2 0
2
-1 0 2
1 0 2


Output

0.0000000000


Input

4 -2 -2 4
3
0 0 2
4 0 1
0 4 1


Output

4.0000000000

Solution (in PYTHON3):

Solution:
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():

    ##########################################
    import heapq
    class Dijkstra():
        """
        ・有向 / 無向は問わない(無向の場合は，逆向きの辺もたす)
        ・負のコストがない場合のみ
        ・計算量はO(E log|V|)　
        ・heapを使うことで頂点を走査する必要がなくなる（代わりに，距離更新したものは確定でなくともqueに入れておく）
        ・復元なし
        """
        
        #最短のpathをたす
        
        
        class Edge():
            #重み付き有向辺
            
            def __init__(self, _to, _cost):
                self.to =_to
                self.cost = _cost
        
        def __init__(self, V,inf):
            #引数Vは頂点数
            self.inf=inf
            self.G = [[] for _ in range(V)] #隣接リストG[u][i]が頂点uのi番目の辺
            self. _E = 0 #辺の数
            self._V = V #頂点数
        
        #proparty - 辺の数
        def E(self):
            return self._E
        
        #proparty - 頂点数
        def V(self):
            return self._V
        
        def add(self, _from, _to, _cost):
            #2頂点と辺のコストを追加
            self.G[_from].append(self.Edge(_to,_cost))
            self._E +=1
            
        def add2(self, _from, _to, _cost):
            #2頂点と辺のコスト（無向）を追加
            self.G[_from].append(self.Edge(_to, _cost))
            self.G[_to].append(self.Edge(_from, _cost))
            self._E +=2
            
        def shortest_path(self,s):#,g):
            #始点sから頂点iまでの最短経路長のリストを返す
            que = [] #priority queue
            d = [self.inf] * self.V()
            
            #prev = [None]*self.V() #prev[j]は，sからjへ最短経路で行くときのjの一つ前の場所
            #復元で使う
            
            d[s] = 0
            heapq.heappush(que,(0,s)) #始点の距離と頂点番号をヒープに追加
            
            while len(que)!=0:
                #キューに格納されてある中で一番コストが小さい頂点を取り出す
                cost,v = heapq.heappop(que)
                
                #キューに格納された最短経路長候補がdの距離よりも大きい場合に処理をスキップ
                if d[v] < cost:
                    continue
                    
                #頂点vに隣接する各頂点iに対して，vを経由した場合の距離を計算して，これがd[i]よりも小さい場合に更新
                for i in range(len(self.G[v])):
                    e = self.G[v][i] #vのi個目の隣接辺
                    if d[e.to] > d[v] + e.cost:
                        d[e.to] = d[v] + e.cost #更新
                        
                        #prev[e.to] = v
                        #復元で使う
                        
                        heapq.heappush(que,(d[e.to],e.to)) #queに新たな最短経路長候補を追加
            
            """#sからgまでの最短経路
            path = []
            pos = g #今いる場所，ゴールで初期化
            for _ in range(self.V()+1):
                path.append(pos)
                if pos == s:
                    break
                #print("pos:",format(pos))
                pos = prev[pos]
            path.reverse()
            #print(path)"""
                        
            return d#,path
    ########################
    mod=10**9+7
    L=LI()
    N=I()
    X=[0]*(N+2)
    Y=[0]*(N+2)
    R=[0]*(N+2)
    
    X[0]=L[0]
    X[-1]=L[2]
    Y[0]=L[1]
    Y[-1]=L[3]
    
    for i in range(N):
        X[i+1],Y[i+1],R[i+1]=MI()
        
        
    djk=Dijkstra(N+2,10**20)
    
    for i in range(N+2):
        for j in range(i+1,N+2):
            diff=( (X[i]-X[j])**2 + (Y[i]-Y[j])**2)**0.5
            cost=max(diff-R[i]-R[j],0)
            djk.add2(i,j,cost)
            
    D=djk.shortest_path(0)
    print(D[-1])
    

main()