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>
using namespace std;
bool debug = false;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
double dd(double x1, double y1, double x2, double y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
double a, b, ax, ay, bx, by;
struct trench {
  int x1, x2, y1, y2, ori, d = 2105;
  double t;
  void init() {
    t = 2105 * (a + b);
    if (x1 == x2) {
      ori = 0;
      if (y1 > y2) swap(y1, y2);
    } else {
      ori = 1;
      if (x1 > x2) swap(x1, x2);
    }
  }
  double dis(double x, double y) {
    double d = min(dd(x, y, x1, y1), dd(x, y, x2, y2));
    if (ori == 0) {
      if (y > y1 && y < y2) d = min(d, abs(x - x1));
    } else if (x > x1 && x < x2)
      d = min(d, abs(y - y1));
    if (d < a || abs(d - a) < 1e-20) return d;
    return 1 << 30;
  }
} tr[2105];
double dist(trench &p, trench &q) {
  return min(min(p.dis(q.x1, q.y1), p.dis(q.x2, q.y2)),
             min(q.dis(p.x1, p.y1), q.dis(p.x2, p.y2)));
}
bool ck(trench &from, trench &to) {
  double dd = dist(from, to);
  if (dd > a + 1e-20) return 0;
  to.t = min(to.t, from.d * (a + b) + dd);
  if (to.d > from.d + 1) {
    to.d = from.d + 1;
    return 1;
  } else {
    return 0;
  }
}
int main() {
  scanf("%lf%lf", &a, &b);
  cin >> ax >> ay >> bx >> by;
  scanf("%d", &n);
  for (int(i) = 0; (i) < (int)(n); (i)++) {
    scanf("%d%d%d%d", &tr[i].x1, &tr[i].y1, &tr[i].x2, &tr[i].y2);
    tr[i].init();
  }
  tr[n].x1 = tr[n].x2 = ax;
  tr[n].y1 = tr[n].y2 = ay;
  tr[n].init();
  n++;
  tr[n].x1 = tr[n].x2 = bx;
  tr[n].y1 = tr[n].y2 = by;
  tr[n].init();
  n++;
  tr[n - 2].d = 0;
  tr[n - 2].t = 0;
  priority_queue<pair<int, int> > q;
  q.push({-tr[n - 2].d, n - 2});
  while (!q.empty()) {
    int d = -q.top().first;
    int k = q.top().second;
    q.pop();
    if (d != tr[k].d) {
      continue;
    }
    for (int i = 0; i < n; ++i) {
      if (tr[i].d > d && ck(tr[k], tr[i])) {
        q.push({-tr[i].d, i});
      }
    }
  }
  if (tr[n - 1].d >= 2105)
    puts("-1");
  else
    printf("%.10lf\n", tr[n - 1].t);
  return 0;
}