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 std::abs;
using std::bitset;
using std::cerr;
using std::cin;
using std::copy;
using std::cout;
using std::deque;
using std::endl;
using std::fill;
using std::fixed;
using std::greater;
using std::iota;
using std::istream;
using std::lower_bound;
using std::make_pair;
using std::make_tuple;
using std::map;
using std::max;
using std::max_element;
using std::min;
using std::min_element;
using std::multiset;
using std::next_permutation;
using std::nth_element;
using std::ostream;
using std::pair;
using std::priority_queue;
using std::queue;
using std::reverse;
using std::rotate;
using std::set;
using std::sort;
using std::string;
using std::swap;
using std::tie;
using std::tuple;
using std::unique;
using std::unordered_map;
using std::unordered_set;
using std::upper_bound;
using std::vector;
long long rnd(long long x, long long y) {
  static auto gen = std::bind(std::uniform_int_distribution<long long>(),
                              std::mt19937(960172));
  return gen() % (y - x + 1) + x;
}
long long gcd(long long a, long long b) {
  while (b > 0) {
    long long t = a % b;
    a = b;
    b = t;
  }
  return a;
}
template <typename T>
T sqr(T const& a) {
  return a * a;
}
int const INF = 100 + (int)1e9;
long long const INFL = 100 + (long long)1e18;
long double const PI = 3.1415926535897932384626433832795028;
long double const EPS = 1e-8;
struct T {
  int x1, y1;
  int x2, y2;
};
long double calc_dist(int x, int y, int xx, int yy) {
  return sqrtl(sqr(x - xx) + sqr(y - yy));
}
int dot(int x, int y, int xx, int yy) { return x * xx + y * yy; }
long double calc_dist(int x, int y, T const& a) {
  long double value = INFL;
  if (dot(x - a.x2, y - a.y2, a.x1 - a.x2, a.y1 - a.y2) > 0 &&
      dot(x - a.x1, y - a.y1, a.x2 - a.x1, a.y2 - a.y1) > 0 &&
      (a.x1 != a.x2 || a.y1 != a.y2)) {
    int A = a.y1 - a.y2;
    int B = a.x2 - a.x1;
    int C = -A * a.x1 - B * a.y1;
    value = abs<long double>(A * x + B * y + C) / sqrt(sqr(A) + sqr(B));
  }
  return min({calc_dist(x, y, a.x1, a.y1), calc_dist(x, y, a.x2, a.y2), value});
}
long double calc_dist(T const& a, T const& b) {
  return min({calc_dist(a.x1, a.y1, b), calc_dist(a.x2, a.y2, b),
              calc_dist(b.x1, b.y1, a), calc_dist(b.x2, b.y2, a)});
}
void solve() {
  int a, b;
  scanf("%d%d", &a, &b);
  vector<T> ts(2);
  for (int i = 0; i < (int)ts.size(); ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    ts[i] = {x, y, x, y};
  }
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int x1, y1, x2, y2;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    ts.push_back({x1, y1, x2, y2});
  }
  n += 2;
  vector<vector<long double>> d(n, vector<long double>(n));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      d[i][j] = calc_dist(ts[i], ts[j]);
      if (d[i][j] > a + EPS) {
        d[i][j] = INF + INF;
      }
    }
  }
  vector<long double> dist(n, 2 * INF);
  dist[0] = 0;
  vector<char> used(n);
  while (true) {
    int v = -1;
    for (int i = 0; i < n; ++i) {
      if (!used[i] && (v < 0 || dist[v] > dist[i])) {
        v = i;
      }
    }
    if (v < 0 || dist[v] > INF) break;
    used[v] = true;
    long double t = dist[v];
    for (int to = 0; to < n; ++to) {
      long double r = t / (a + b);
      int cn = (int)r;
      if (r > cn + EPS) {
        ++cn;
      }
      long double new_t = cn * (a + b) + d[v][to];
      dist[to] = min(dist[to], new_t);
    }
  }
  if (dist[1] > INF) {
    puts("-1");
  } else {
    cout << (double)dist[1] << endl;
  }
}
int main() {
  cout.precision(15);
  cout << fixed;
  cerr.precision(6);
  cerr << fixed;
  solve();
}