#include <bits/stdc++.h>
using namespace std;
struct aaa {
  int xx1, x2, yy1, y2;
} a[2001];
int n, aa, bb, f[2001], xx1, x2, yy1, y2, dis[2001][2001];
double ans;
int sqr(int x) { return x * x; }
void dfs(int x) {
  int i;
  for (i = 1; i <= n; i++)
    if (dis[x][i] > 0 && f[i] > f[x] + 1) {
      f[i] = f[x] + 1;
      dfs(i);
    }
}
int main() {
  ans = 1e9;
  int i, j;
  scanf("%d%d", &aa, &bb);
  scanf("%d%d%d%d", &xx1, &yy1, &x2, &y2);
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d%d%d%d", &a[i].xx1, &a[i].yy1, &a[i].x2, &a[i].y2);
    if (a[i].xx1 == a[i].x2) {
      if (a[i].yy1 > a[i].y2) swap(a[i].yy1, a[i].y2);
    } else if (a[i].xx1 > a[i].x2)
      swap(a[i].xx1, a[i].x2);
    f[i] = n + 2;
  }
  a[n + 1].xx1 = a[n + 1].x2 = xx1;
  a[n + 1].yy1 = a[n + 1].y2 = yy1;
  a[n + 2].xx1 = a[n + 2].x2 = x2;
  a[n + 2].yy1 = a[n + 2].y2 = y2;
  n += 2;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) {
      dis[i][j] = sqr(max(0, max(a[i].xx1, a[j].xx1) - min(a[i].x2, a[j].x2))) +
                  sqr(max(0, max(a[i].yy1, a[j].yy1) - min(a[i].y2, a[j].y2)));
      if (dis[i][j] > aa * aa) dis[i][j] = 0;
    }
  f[n - 1] = 0;
  f[n] = n;
  dfs(n - 1);
  if (f[n] == n) return puts("-1"), 0;
  for (i = 1; i < n; i++)
    if (dis[i][n] && f[i] * (aa + bb) + sqrt(dis[i][n]) < ans)
      ans = f[i] * (aa + bb) + sqrt(dis[i][n]);
  printf("%.10lf", ans);
}
