#include <bits/stdc++.h>
using namespace std;
struct point {
  int x, y;
};
struct trench {
  point a, b;
};
trench p[1010];
double pdis(point a, point b) {
  return sqrt(double((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)));
}
double calc(point a, trench b) {
  if (b.a.x == b.b.x)
    if ((b.a.y - a.y) * (b.b.y - a.y) <= 0)
      return abs(b.a.x - a.x);
    else
      return min(pdis(a, b.a), pdis(a, b.b));
  else if ((b.a.x - a.x) * (b.b.x - a.x) <= 0)
    return abs(b.a.y - a.y);
  else
    return min(pdis(a, b.a), pdis(a, b.b));
}
double dis(trench a, trench b) {
  return min(min(calc(a.a, b), calc(a.b, b)), min(calc(b.a, a), calc(b.b, a)));
}
int g[1010][1010];
int dist[1010], vis[1010];
void lemon() {
  int delay, shooting;
  scanf("%d%d", &delay, &shooting);
  point e;
  scanf("%d%d%d%d", &p[0].a.x, &p[0].a.y, &e.x, &e.y);
  p[0].b = p[0].a;
  int n;
  scanf("%d", &n);
  for (int i = (1); i <= (n); i++)
    scanf("%d%d%d%d", &p[i].a.x, &p[i].a.y, &p[i].b.x, &p[i].b.y);
  for (int i = (0); i <= (n); i++)
    for (int j = (0); j <= (n); j++)
      if (dis(p[i], p[j]) <= delay + 1e-9)
        g[i][j] = 1;
      else
        g[i][j] = 1000000000;
  for (int i = (0); i <= (n); i++) dist[i] = 1000000000;
  dist[0] = 0;
  memset(vis, 0, sizeof vis);
  for (int i = (0); i <= (n); i++) {
    int mi = 1000000000, mini = 0;
    for (int i = (0); i <= (n); i++)
      if (!vis[i] && dist[i] < mi) mi = dist[i], mini = i;
    if (mi == 1000000000) break;
    vis[mini] = 1;
    for (int i = (0); i <= (n); i++)
      dist[i] = min(dist[i], dist[mini] + g[mini][i]);
  }
  double final = 1000000000;
  for (int i = (0); i <= (n); i++) {
    double x = calc(e, p[i]);
    if (x <= delay + 1e-9 && dist[i] != 1000000000)
      final = min(final, double(dist[i]) * (delay + shooting) + x);
  }
  if (final + 1e-9 >= 1000000000)
    printf("-1\n");
  else
    printf("%.20lf\n", final);
}
int main() {
  ios::sync_with_stdio(true);
  lemon();
  return 0;
}
