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;
const int MAX = 3e5 + 10;
const long long MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long LLINF = 0x3f3f3f3f3f3f3f3f;
const long double EPS = 1e-7;
const long double PI = acos(-1);
bool eq(long double a, long double b) { return abs(a - b) <= EPS; }
struct point {
  long double x, y;
  int id;
  point(long double x = 0, long double y = 0) : x(x), y(y) {}
  point operator+(const point &o) const { return {x + o.x, y + o.y}; }
  point operator-(const point &o) const { return {x - o.x, y - o.y}; }
  point operator*(long double t) const { return {x * t, y * t}; }
  point operator/(long double t) const { return {x / t, y / t}; }
  long double operator*(const point &o) const { return x * o.x + y * o.y; }
  long double operator^(const point &o) const { return x * o.y - y * o.x; }
  bool operator<(const point &o) const {
    if (!eq(x, o.x)) return x < o.x;
    return y < o.y;
  }
  bool operator==(const point &o) const { return eq(x, o.x) and eq(y, o.y); }
};
long double norm(point a) { return sqrt(a * a); }
struct line {
  point p1, p2;
  long double a, b, c;
  line(point p1 = 0, point p2 = 0) : p1(p1), p2(p2) {
    a = p1.y - p2.y;
    b = p2.x - p1.x;
    c = -(a * p1.x + b * p1.y);
  }
  long double eval(point p) { return a * p.x + b * p.y + c; }
  bool inside(point p) { return eq(eval(p), 0); }
  point normal() { return point(a, b); }
  bool inside_seg(point p) {
    return (inside(p) and min(p1.x, p2.x) <= p.x and p.x <= max(p1.x, p2.x) and
            min(p1.y, p2.y) <= p.y and p.y <= max(p1.y, p2.y));
  }
};
long double dseg(point p, point a, point b) {
  if (((p - a) * (b - a)) < EPS) return norm(p - a);
  if (((p - b) * (a - b)) < EPS) return norm(p - b);
  return abs((p - a) ^ (b - a)) / norm(b - a);
}
vector<vector<pair<long double, long double>>> g(
    MAX + 1, vector<pair<long double, long double>>());
vector<long double> d(MAX + 1, LLINF);
priority_queue<pair<long double, long double>,
               vector<pair<long double, long double>>,
               greater<pair<long double, long double>>>
    fila;
void dijkstra(int k) {
  d[k] = 0;
  fila.push({0, k});
  while (!fila.empty()) {
    long double w = fila.top().first, u = fila.top().second;
    fila.pop();
    if (w > d[u]) continue;
    for (auto [v, w] : g[u]) {
      if (d[v] > d[u] + w) {
        d[v] = d[u] + w;
        fila.push({d[v], v});
      }
    }
  }
}
long double pDist(point p, pair<point, point> t) {
  return dseg(p, t.first, t.second);
}
long double trenchDist(pair<point, point> A, pair<point, point> B) {
  long double ans = LLINF;
  ans = min(ans, pDist(A.first, B));
  ans = min(ans, pDist(A.second, B));
  ans = min(ans, pDist(B.first, A));
  ans = min(ans, pDist(B.second, A));
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  cout << fixed << setprecision(6);
  int a, b, Ax, Ay, Bx, By;
  cin >> a >> b;
  cin >> Ax >> Ay >> Bx >> By;
  int n, x1, y1, x2, y2;
  cin >> n;
  vector<pair<point, point>> vt(n);
  for (int i = 0; i < n; i++) {
    cin >> x1 >> y1 >> x2 >> y2;
    vt[i].first = point(x1, y1);
    vt[i].second = point(x2, y2);
  }
  point pA = point(Ax, Ay);
  point pB = point(Bx, By);
  if (norm(pA - pB) <= a) {
    cout << norm(pA - pB) << '\n';
    return 0;
  }
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) {
      long double dist = trenchDist(vt[i], vt[j]);
      if (dist <= a + EPS) {
        g[i].push_back({j, a + b});
        g[j].push_back({i, a + b});
      }
    }
  for (int i = 0; i < n; i++) {
    long double dist = pDist(pA, vt[i]);
    if (dist <= a + EPS) g[n].push_back({i, a + b});
  }
  for (int i = 0; i < n; i++) {
    long double dist = pDist(pB, vt[i]);
    if (dist <= a + EPS) g[i].push_back({n + 1, dist});
  }
  dijkstra(n);
  if (d[n + 1] == LLINF)
    cout << -1 << '\n';
  else
    cout << d[n + 1] << '\n';
  return 0;
}