#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
struct arr {
  int x1, y1, x2, y2;
} a[maxn];
double g[maxn][maxn], d[maxn];
int f[maxn], q[maxn];
bool v[maxn];
int n, t1, t2;
double dis(int i, int j) {
  int x1, x2, y1, y2;
  x1 = max(a[i].x1, a[j].x1);
  x2 = min(a[i].x2, a[j].x2);
  y1 = max(a[i].y1, a[j].y1);
  y2 = min(a[i].y2, a[j].y2);
  x2 = max(x1 - x2, 0);
  y2 = max(y1 - y2, 0);
  return sqrt(x2 * x2 + y2 * y2);
}
void spfa() {
  int h = -1, t = 0, i, k;
  for (i = 0; i <= n; i++) d[i] = -1;
  v[0] = 1;
  d[0] = 0;
  q[0] = 0;
  while (h < t) {
    k = q[++h];
    for (i = 0; i < n; i++)
      if (g[k][i] <= t1)
        if (g[k][i] + f[k] * t2 < d[i] || d[i] < 0) {
          d[i] = g[k][i] + f[k] * t2;
          f[i] = f[k] + 1;
          if (!v[i]) {
            q[++t] = i;
            v[i] = 1;
          }
        }
    v[k] = 0;
  }
}
int main() {
  int i, j;
  scanf("%d%d", &t1, &t2);
  t2 += t1;
  scanf("%d%d%d%d", &a[0].x1, &a[0].y1, &a[1].x1, &a[1].y1);
  scanf("%d", &n);
  for (i = 0; i < 2; i++) {
    a[i].x2 = a[i].x1;
    a[i].y2 = a[i].y1;
  }
  n += 2;
  for (i = 2; i < n; i++) {
    scanf("%d%d%d%d", &a[i].x1, &a[i].y1, &a[i].x2, &a[i].y2);
    if (a[i].x1 > a[i].x2) swap(a[i].x1, a[i].x2);
    if (a[i].y1 > a[i].y2) swap(a[i].y1, a[i].y2);
  }
  for (i = 1; i < n; i++)
    for (j = 0; j < i; j++) g[i][j] = g[j][i] = dis(i, j);
  spfa();
  if (d[1] < 0)
    printf("-1\n");
  else
    printf("%.10f\n", d[1]);
  return 0;
}
