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;
long double sqr(long double a) { return a * a; }
struct Point {
  long double x, y;
  Point(long double x0 = 0, long double y0 = 0, long long int ind = 0) {
    this->x = x0;
    this->y = y0;
  }
};
bool operator==(const Point& a, const Point& b) {
  return a.x == b.x && a.y == b.y;
}
bool operator<(const Point& a, const Point& b) {
  return a.x < b.x || (a.x == b.x && a.y < b.y);
}
struct Vector {
  long double x, y;
  long long int ind;
  Vector(long double x0 = 0, long double y0 = 0) {
    this->x = x0;
    this->y = y0;
  }
  Vector(const Point& A, const Point& B, long long int ind = 0) {
    this->x = B.x - A.x;
    this->y = B.y - A.y;
    this->ind = ind;
  }
  long double len() { return sqrt(x * x + y * y); }
  long double angle() const { return atan2(y, x); }
};
Vector operator/(Vector A, long double d) { return Vector(A.x / d, A.y / d); };
Vector operator*(Vector A, long double d) { return Vector(A.x * d, A.y * d); };
Point operator+(Point A, Vector B) { return Point(A.x + B.x, A.y + B.y); }
struct Line {
  long double a, b, c;
  Line(long double a0 = 0, long double b0 = 0, long double c0 = 0) {
    this->a = a0;
    this->b = b0;
    this->c = c0;
  }
  Line(Point& A, Point& B) {
    Vector AB(A, B);
    b = -AB.x;
    a = AB.y;
    c = -a * A.x - b * A.y;
  }
  Line(Point& A, Vector& C) {
    Point B = A + C;
    Line(A, B);
  }
  Vector normal() { return Vector(a, b); }
  Point getPoint() {
    long double x = -(a * c) / (a * a + b * b);
    long double y = -(b * c) / (a * a + b * b);
    return Point(x, y);
  }
  long double get(Point& A) { return a * A.x + b * A.y + c; }
  long double perp_sz(const Point& C) {
    assert(sqrt(a * a + b * b) != 0);
    return (a * C.x + b * C.y + c) / sqrt(a * a + b * b);
  }
  Point proection(const Point& A) {
    long double d = perp_sz(A);
    Vector n = normal();
    n = n / n.len();
    Vector n1 = n * d, n2 = n * (-d);
    Point A1 = A + n1, A2 = A + n2;
    if (get(A1) == 0)
      return A1;
    else
      return A2;
  }
};
long double dot_product(const Vector& A, const Vector& B) {
  return A.x * B.x + A.y * B.y;
}
long double cross_product(const Vector& A, const Vector& B) {
  return A.x * B.y - A.y * B.x;
}
long double dist(Point A, Point B) {
  Vector AB(A, B);
  return AB.len();
}
long double dist(Point A, Point B, Point C) {
  Vector BC(B, C), CB(C, B), BA(B, A), CA(C, A);
  Line l(B, C);
  if (dot_product(BC, BA) >= 0 && dot_product(CB, CA) >= 0)
    return fabs(l.perp_sz(A));
  else if (dot_product(BC, BA) < 0)
    return dist(A, B);
  else
    return dist(A, C);
}
long double dist(Point A, Point B, Point C, Point D) {
  return min({dist(A, C, D), dist(B, C, D), dist(C, A, B), dist(D, A, B)});
}
long long int sx, sy, fx, fy, n;
long double a, b;
struct segment {
  vector<Point> coord;
  segment(long long int fx = 0, long long int fy = 0, long long int sx = 0,
          long long int sy = 0) {
    this->coord = {Point(fx, fy), Point(sx, sy)};
  }
};
vector<segment> segm;
vector<vector<pair<long double, long long int>>> g;
signed main() {
  cin >> a >> b >> sx >> sy >> fx >> fy >> n;
  segm.push_back(segment(sx, sy, sx, sy));
  segm.push_back(segment(fx, fy, fx, fy));
  for (long long int i = 0; i < n; i++) {
    long long int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    segm.push_back(segment(x1, y1, x2, y2));
  }
  n = (long long int)segm.size();
  g.resize(n);
  long double d = dist(segm[0].coord[0], segm[1].coord[1]);
  if (d <= a) {
    g[0].push_back({d, 1});
    g[1].push_back({d, 0});
  }
  for (long long int i = 0; i < 2; i++) {
    for (long long int j = 2; j < n; j++) {
      if (i == j) continue;
      long double d =
          dist(segm[i].coord[0], segm[j].coord[0], segm[j].coord[1]);
      if (d <= a) {
        g[i].push_back({d, j});
        g[j].push_back({d, i});
      }
    }
  }
  for (long long int i = 2; i < n; i++) {
    for (long long int j = 2; j < n; j++) {
      if (i == j) continue;
      long double d = dist(segm[i].coord[0], segm[i].coord[1], segm[j].coord[0],
                           segm[j].coord[1]);
      if (d <= a) g[i].push_back({d, j});
    }
  }
  vector<long double> dist(n, 1e15);
  dist[0] = 0;
  set<pair<long double, long long int>> se;
  se.insert({0, 0});
  long double ans = 1e15;
  while (!se.empty()) {
    long long int v = (*se.begin()).second;
    se.erase(se.begin());
    for (auto e : g[v]) {
      long double w = e.first;
      long long int to = e.second;
      long double nextT = ceil((dist[v] + w) / (a + b)) * (a + b);
      if (to == 1) ans = min(ans, dist[v] + w);
      if (dist[to] > nextT) {
        se.erase({dist[to], to});
        dist[to] = nextT;
        se.insert({dist[to], to});
      }
    }
  }
  cout.precision(20);
  if (ans > 1e13)
    cout << -1 << "\n";
  else
    cout << ans << "\n";
  return 0;
}