Problem: Vasya lagged behind at the University and got to the battlefield. Just joking! He's simply playing some computer game. The field is a flat platform with n trenches dug on it. The trenches are segments on a plane parallel to the coordinate axes. No two trenches intersect.

There is a huge enemy laser far away from Vasya. The laser charges for a seconds, and then shoots continuously for b seconds. Then, it charges for a seconds again. Then it shoots continuously for b seconds again and so on. Vasya knows numbers a and b. He also knows that while the laser is shooting, Vasya must be in the trench, but while the laser is charging, Vasya can safely move around the field. The main thing is to have time to hide in the trench before the shot. If Vasya reaches the trench exactly at the moment when the laser starts shooting, we believe that Vasya managed to hide. Coincidentally, the length of any trench in meters numerically does not exceed b.

Initially, Vasya is at point A. He needs to get to point B. Vasya moves at speed 1 meter per second in either direction. You can get in or out of the trench at any its point. Getting in or out of the trench takes no time. It is also possible to move in the trench, without leaving it.

What is the minimum time Vasya needs to get from point A to point B, if at the initial time the laser has just started charging? If Vasya cannot get from point A to point B, print -1. If Vasya reaches point B at the moment when the laser begins to shoot, it is believed that Vasya managed to reach point B.

Input

The first line contains two space-separated integers: a and b (1 ≤ a, b ≤ 1000), — the duration of charging and the duration of shooting, in seconds.

The second line contains four space-separated integers: Ax, Ay, Bx, By ( - 104 ≤ Ax, Ay, Bx, By ≤ 104) — the coordinates of points А and B. It is guaranteed that points A and B do not belong to any trench.

The third line contains a single integer: n (1 ≤ n ≤ 1000), — the number of trenches. 

Each of the following n lines contains four space-separated integers: x1, y1, x2, y2 ( - 104 ≤ xi, yi ≤ 104) — the coordinates of ends of the corresponding trench.

All coordinates are given in meters. It is guaranteed that for any trench either x1 = x2, or y1 = y2. No two trenches intersect. The length of any trench in meters doesn't exceed b numerically.

Output

If Vasya can get from point A to point B, print the minimum time he will need for it. Otherwise, print number -1.

The answer will be considered correct if the absolute or relative error does not exceed 10 - 4

Examples

Input

2 4
0 5 6 5
3
0 0 0 4
1 1 4 1
6 0 6 4


Output

19.0000000000


Input

5 10
0 0 10 10
1
5 0 5 9


Output

-1

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
const double eps = 1e-9;
const int int_inf = 2000000000;
const long long i64_inf = 1000000000000000000LL;
const double pi = acos(-1.0);
using namespace std;
struct p {
  int x, y;
  p(){};
};
struct tr {
  p a, b;
  tr(int x1 = 0, int y1 = 0, int x2 = 0, int y2 = 0) {
    a.x = x1;
    a.y = y1;
    b.x = x2;
    b.y = y2;
  };
};
int dest(tr F, tr S) {
  if (F.a.x == F.b.x && S.a.x == S.b.x) {
    int y = F.a.y;
    int yy = F.b.y;
    int y1 = S.a.y;
    int yy1 = S.b.y;
    if (min(y, yy) > max(y1, yy1) || min(y1, yy1) > max(y, yy)) {
      if (y1 < yy1) swap(y1, yy1);
      if (y < yy) swap(y, yy);
      int dx = abs(F.a.x - S.b.x);
      int dy = min(abs(yy1 - y), abs(y1 - yy));
      return dx * dx + dy * dy;
    } else
      return (F.a.x - S.a.x) * (F.a.x - S.a.x);
  } else if (F.a.y == F.b.y && S.a.y == S.b.y) {
    int x = F.a.x;
    int xx = F.b.x;
    int x1 = S.a.x;
    int xx1 = S.b.x;
    if (min(x, xx) > max(x1, xx1) || min(x1, xx1) > max(x, xx)) {
      if (x1 < xx1) swap(x1, xx1);
      if (x < xx) swap(x, xx);
      int dy = abs(F.a.y - S.b.y);
      int dx = min(abs(xx1 - x), abs(x1 - xx));
      return dx * dx + dy * dy;
    } else
      return (F.a.y - S.a.y) * (F.a.y - S.a.y);
  } else {
    if (F.a.y == F.b.y) swap(F, S);
    int y = F.b.y;
    int y1 = F.a.y;
    int x = S.a.x;
    int x1 = S.b.x;
    if (y1 < y) swap(y, y1);
    if (x1 < x) swap(x, x1);
    if (S.a.y <= y1 && S.a.y >= y)
      return min((x - F.b.x) * (x - F.b.x), (x1 - F.b.x) * (x1 - F.b.x));
    if (F.a.x >= x && F.a.x <= x1)
      return min((y1 - S.a.y) * (y1 - S.a.y), (y - S.a.y) * (y - S.a.y));
    if (abs(x - F.a.x) > abs(x1 - F.a.x)) swap(x, x1);
    if (abs(y - S.a.y) < abs(y1 - S.a.y)) swap(y, y1);
    int dx = F.a.x - x;
    int dy = y1 - S.a.y;
    return dx * dx + dy * dy;
  }
}
int n;
int a, aa, b;
p A;
p B;
tr c[1100];
int d[1050];
int main() {
  cin >> a >> b;
  aa = a;
  a = a * a;
  cin >> A.x >> A.y >> B.x >> B.y;
  cin >> n;
  for (int i = 0; i < (int)n; i++)
    scanf("%d%d%d%d", &c[i].a.x, &c[i].a.y, &c[i].b.x, &c[i].b.y);
  if ((A.x - B.x) * (A.x - B.x) + (A.y - B.y) * (A.y - B.y) <= a) {
    int de = (A.x - B.x) * (A.x - B.x) + (A.y - B.y) * (A.y - B.y);
    printf("%.8lf", (double)sqrt((double)de));
    return 0;
  }
  for (int i = 0; i < (int)n; i++)
    if (dest(tr(A.x, A.y, A.x, A.y), c[i]) <= a)
      d[i] = 1;
    else
      d[i] = int_inf;
  queue<int> q;
  for (int i = 0; i < (int)n; i++)
    if (d[i] < int_inf) q.push(i);
  double res = int_inf;
  while (!q.empty()) {
    int j = q.front();
    q.pop();
    if (dest(tr(B.x, B.y, B.x, B.y), c[j]) <= a)
      res = min(res,
                (double)d[j] * (aa + b) +
                    (double)sqrt((double)dest(tr(B.x, B.y, B.x, B.y), c[j])));
    for (int i = 0; i < (int)n; i++)
      if (dest(c[i], c[j]) <= a && i != j && d[i] > d[j] + 1)
        q.push(i), d[i] = d[j] + 1;
  }
  if (res == int_inf) {
    cout << "-1";
    return 0;
  }
  printf("%.8lf", (double)res);
  return 0;
}