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:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub
from pprint import pprint

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def Dijkstra(g, s):
    d = {}
    q = []
    heapq.heappush(q, (0, s))

    while q:
        c, u = heapq.heappop(q)
        if u in d:
            continue
        d[u] = c
        for v in g[u]:
            if v not in d:
                heapq.heappush(q, (g[u][v] + c, v))
    return d


@mt
def slv(N, XY, YS, XT, YT, XYR):
    p = [(XY, YS, 0, -1), (XT, YT, 0, -2)]
    for i, (x, y, r) in enumerate(XYR):
        p.append((x, y, r, i))

    def cost(p1, p2):
        c = math.sqrt((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2) - p1[2] - p2[2]
        return max(0, c)

    g = defaultdict(dict)
    for i in range(N+2):
        for j in range(N+2):
            if i == j:
                continue
            d = cost(p[i], p[j])
            g[p[i][3]][p[j][3]] = d
            g[p[j][3]][p[i][3]] = d

    return Dijkstra(g, -1)[-2]


def main():
    XS, YS, XT, YT = read_int_n()
    N = read_int()
    XYR = [read_int_n() for _ in range(N)]
    print(slv(N, XS, YS, XT, YT, XYR))


if __name__ == '__main__':
    main()