#include <bits/stdc++.h>
using namespace std;
struct rectangle {
  long long x1, x2, y1, y2;
  rectangle() {}
  rectangle(int ax, int ay, int bx, int by) {
    x1 = min(ax, bx);
    x2 = max(ax, bx);
    y1 = min(ay, by);
    y2 = max(ay, by);
  }
  long long dist2(rectangle u) {
    int dx = 0, dy = 0;
    if (x2 < u.x1)
      dx = u.x1 - x2;
    else if (u.x2 < x1)
      dx = x1 - u.x2;
    if (y2 < u.y1)
      dy = u.y1 - y2;
    else if (u.y2 < y1)
      dy = y1 - u.y2;
    return dx * dx + dy * dy;
  }
} P[1002], Last;
int n;
long long a, b;
long long ax, ay, bx, by;
bool linked[1002][1002];
long long dist[1002];
int Q[1100001], now, z;
long long INF = 100000000;
int MAIN() {
  cin >> a >> b;
  cin >> ax >> ay >> bx >> by;
  cin >> n;
  P[0] = rectangle(ax, ay, ax, ay);
  P[n + 1] = rectangle(bx, by, bx, by);
  for (int i = 1; i <= n; i++) {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    P[i] = rectangle(x1, y1, x2, y2);
  }
  for (int i = 0; i <= n + 1; i++)
    for (int j = 0; j <= n + 1; j++)
      if (P[i].dist2(P[j]) <= a * a)
        linked[i][j] = true;
      else
        linked[i][j] = false;
  Q[0] = 0, now = 0, z = 0;
  for (int i = 1; i <= n + 1; i++) dist[i] = INF;
  dist[0] = 0;
  while (now <= z) {
    int s = Q[now];
    for (int i = 0; i <= n; i++)
      if (linked[s][i])
        if (dist[i] > dist[s] + 1) {
          dist[i] = dist[s] + 1;
          Q[++z] = i;
        }
    ++now;
  }
  double ans = INF;
  for (int i = 0; i <= n; i++)
    if (linked[i][n + 1]) {
      double d = double(a + b) * dist[i];
      d += sqrt(P[i].dist2(P[n + 1]));
      ans = min(ans, d);
    }
  if (ans == INF)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}
int main() {
  ios ::sync_with_stdio(false);
  cout << fixed << setprecision(16);
  int RUN_RESULT = MAIN();
  return RUN_RESULT;
}
