#include <bits/stdc++.h>
using namespace std;
vector<int> v[1010];
queue<int> q;
bool check(int X1_1, int Y1_1, int X1_2, int Y1_2, int X2_1, int Y2_1, int X2_2,
           int Y2_2, int maxdist) {
  int mini = maxdist * maxdist + 1;
  int dist1 = (X1_1 - X2_1) * (X1_1 - X2_1) + (Y1_1 - Y2_1) * (Y1_1 - Y2_1);
  int dist2 = (X1_1 - X2_2) * (X1_1 - X2_2) + (Y1_1 - Y2_2) * (Y1_1 - Y2_2);
  int dist3 = (X1_2 - X2_1) * (X1_2 - X2_1) + (Y1_2 - Y2_1) * (Y1_2 - Y2_1);
  int dist4 = (X1_2 - X2_2) * (X1_2 - X2_2) + (Y1_2 - Y2_2) * (Y1_2 - Y2_2);
  mini = min(min(dist1, dist2), min(dist3, dist4));
  if (X1_1 > X1_2) {
    swap(X1_1, X1_2);
    swap(Y1_1, Y1_2);
  }
  if (X2_1 > X2_2) {
    swap(X2_1, X2_2);
    swap(Y2_1, Y2_2);
  }
  int dist5 = maxdist * maxdist + 1;
  if (X1_1 <= X2_1 && X1_2 >= X2_1 || X1_1 <= X2_2 && X1_2 >= X2_2 ||
      X2_1 <= X1_1 && X2_2 >= X1_1 || X2_1 <= X1_2 && X2_2 >= X1_2)
    dist5 =
        min(min((Y1_1 - Y2_1) * (Y1_1 - Y2_1), (Y1_1 - Y2_2) * (Y1_1 - Y2_2)),
            min((Y1_2 - Y2_1) * (Y1_2 - Y2_1), (Y1_2 - Y2_2) * (Y1_2 - Y2_2)));
  if (Y1_1 > Y1_2) {
    swap(X1_1, X1_2);
    swap(Y1_1, Y1_2);
  }
  if (Y2_1 > Y2_2) {
    swap(X2_1, X2_2);
    swap(Y2_1, Y2_2);
  }
  int dist6 = maxdist * maxdist + 1;
  if (Y1_1 <= Y2_1 && Y1_2 >= Y2_1 || Y1_1 <= Y2_2 && Y1_2 >= Y2_2 ||
      Y2_1 <= Y1_1 && Y2_2 >= Y1_1 || Y2_1 <= Y1_2 && Y2_2 >= Y1_2)
    dist6 =
        min(min((X1_1 - X2_1) * (X1_1 - X2_1), (X1_1 - X2_2) * (X1_1 - X2_2)),
            min((X1_2 - X2_1) * (X1_2 - X2_1), (X1_2 - X2_2) * (X1_2 - X2_2)));
  if (dist5 < mini) mini = dist5;
  if (dist6 < mini) mini = dist6;
  if (mini > maxdist * maxdist) return false;
  return true;
}
double getdist(int X1_1, int Y1_1, int X1_2, int Y1_2, int X2_1, int Y2_1,
               int X2_2, int Y2_2) {
  int mini = 1000000000;
  int dist1 = (X1_1 - X2_1) * (X1_1 - X2_1) + (Y1_1 - Y2_1) * (Y1_1 - Y2_1);
  int dist2 = (X1_1 - X2_2) * (X1_1 - X2_2) + (Y1_1 - Y2_2) * (Y1_1 - Y2_2);
  int dist3 = (X1_2 - X2_1) * (X1_2 - X2_1) + (Y1_2 - Y2_1) * (Y1_2 - Y2_1);
  int dist4 = (X1_2 - X2_2) * (X1_2 - X2_2) + (Y1_2 - Y2_2) * (Y1_2 - Y2_2);
  mini = min(min(dist1, dist2), min(dist3, dist4));
  if (X1_1 > X1_2) {
    swap(X1_1, X1_2);
    swap(Y1_1, Y1_2);
  }
  if (X2_1 > X2_2) {
    swap(X2_1, X2_2);
    swap(Y2_1, Y2_2);
  }
  int dist5 = 1000000000;
  if (X1_1 <= X2_1 && X1_2 >= X2_1 || X1_1 <= X2_2 && X1_2 >= X2_2 ||
      X2_1 <= X1_1 && X2_2 >= X1_1 || X2_1 <= X1_2 && X2_2 >= X1_2)
    dist5 =
        min(min((Y1_1 - Y2_1) * (Y1_1 - Y2_1), (Y1_1 - Y2_2) * (Y1_1 - Y2_2)),
            min((Y1_2 - Y2_1) * (Y1_2 - Y2_1), (Y1_2 - Y2_2) * (Y1_2 - Y2_2)));
  if (Y1_1 > Y1_2) {
    swap(X1_1, X1_2);
    swap(Y1_1, Y1_2);
  }
  if (Y2_1 > Y2_2) {
    swap(X2_1, X2_2);
    swap(Y2_1, Y2_2);
  }
  int dist6 = 1000000000;
  if (Y1_1 <= Y2_1 && Y1_2 >= Y2_1 || Y1_1 <= Y2_2 && Y1_2 >= Y2_2 ||
      Y2_1 <= Y1_1 && Y2_2 >= Y1_1 || Y2_1 <= Y1_2 && Y2_2 >= Y1_2)
    dist6 =
        min(min((X1_1 - X2_1) * (X1_1 - X2_1), (X1_1 - X2_2) * (X1_1 - X2_2)),
            min((X1_2 - X2_1) * (X1_2 - X2_1), (X1_2 - X2_2) * (X1_2 - X2_2)));
  if (dist5 < mini) mini = dist5;
  if (dist6 < mini) mini = dist6;
  return sqrt((double)mini);
}
int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  int Bx, By;
  int transh[1010][4];
  scanf("%d %d %d %d", &transh[0][0], &transh[0][1], &Bx, &By);
  transh[0][2] = transh[0][0];
  transh[0][3] = transh[0][1];
  int n;
  scanf("%d", &n);
  transh[n + 1][0] = Bx;
  transh[n + 1][1] = By;
  transh[n + 1][2] = Bx;
  transh[n + 1][3] = By;
  for (int i = 1; i <= n; i++)
    scanf("%d %d %d %d", &transh[i][0], &transh[i][1], &transh[i][2],
          &transh[i][3]);
  for (int i = 0; i <= n; i++) {
    for (int j = i + 1; j <= n + 1; j++) {
      if (check(transh[i][0], transh[i][1], transh[i][2], transh[i][3],
                transh[j][0], transh[j][1], transh[j][2], transh[j][3], a)) {
        v[i].push_back(j);
        v[j].push_back(i);
      }
    }
  }
  double answer = 1000000000.0;
  q.push(0);
  int steps = 0;
  bool visited[1010];
  for (int i = 0; i < 1010; i++) visited[i] = false;
  while (!q.empty() && steps <= n + 5) {
    for (int i = 0, j = q.size(); i < j; i++) {
      int x = q.front();
      q.pop();
      for (int k = 0, maxi = v[x].size(); k < maxi; k++) {
        if (v[x][k] == n + 1)
          answer = min(answer, (double)steps * (double)(a + b) +
                                   getdist(transh[x][0], transh[x][1],
                                           transh[x][2], transh[x][3],
                                           transh[n + 1][0], transh[n + 1][1],
                                           transh[n + 1][2], transh[n + 1][3]));
        if (!visited[v[x][k]]) q.push(v[x][k]);
        visited[v[x][k]] = true;
      }
    }
    if (answer < 999999999.0) break;
    steps++;
  }
  if (steps >= n + 3 || q.empty())
    printf("-1\n");
  else
    printf("%lf\n", answer);
  return 0;
}
