#include <bits/stdc++.h>
using namespace std;
double PI = acos(-1);
struct point {
  double x, y;
  int cs;
  point(double x = 0, double y = 0) {
    this->x = x;
    this->y = y;
  }
  bool operator==(point& p) { return p.x == x && p.y == y; }
  bool operator<(const point& p) const {
    if (y == p.y) return x < p.x;
    return y < p.y;
  }
  point rotate(double alpha) {
    return point(x * cos(alpha) - y * sin(alpha),
                 x * sin(alpha) + y * cos(alpha));
  }
} botLeft, topRight;
struct line {
  double a, b, c;
  point A, B;
  line(double a, double b, double c) : a(a), b(b), c(c) {}
  line(point A, point B) : A(A), B(B) {
    a = B.y - A.y;
    b = A.x - B.x;
    c = -(a * A.x + b * A.y);
  }
  line(point P, double m) {
    a = -m;
    b = 1;
    c = -((a * P.x) + (b * P.y));
  }
  double f(point A) { return a * A.x + b * A.y + c; }
};
vector<line> a;
vector<point> g[100010];
vector<point> P;
struct vecto {
  double x, y;
  vecto(double x = 0, double y = 0) {
    this->x = x;
    this->y = y;
  }
  bool operator==(vecto& v) { return v.x == x && v.y == y; }
  bool operator<(const vecto& v) const {
    if (v.x == x) return y < v.y;
    return x < v.x;
  }
};
vecto toVec(point a, point b) { return vecto(b.x - a.x, b.y - a.y); }
double crossProduct(vecto a, vecto b) { return a.x * b.y - a.y * b.x; }
long long dotProduct(vecto a, vecto b) { return a.x * b.x + a.y * b.y; }
long long dist(point a, point b) {
  return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}
double DEG_to_RAD(double d) { return d * PI / 180.0; }
double RAD_to_DEG(double r) { return r * 180.0 / PI; }
inline int cmp(double a, double b) {
  return (a < b - 1e-9) ? -1 : ((a > b + 1e-9) ? 1 : 0);
}
bool areParallel(line l1, line l2) {
  return cmp(l1.a * l2.b, l1.b * l2.a) == 0;
}
bool areIntersect(line l1, line l2, point& p) {
  if (areParallel(l1, l2)) return false;
  double dx = l1.b * l2.c - l2.b * l1.c;
  double dy = l1.c * l2.a - l2.c * l1.a;
  double d = l1.a * l2.b - l2.a * l1.b;
  p = point(dx / d, dy / d);
  return true;
}
bool check(point P, line l) {
  vecto a = toVec(l.A, l.B);
  vecto b = toVec(l.A, P);
  return (a.x * b.x >= 0 && a.y * b.y >= 0);
}
bool isOneSide(line L) {
  bool isNeg = false, isPos = false;
  for (int i = (0); i <= (int((P).size()) - 1); i++) {
    point A = P[i];
    double k = crossProduct(toVec(L.A, L.B), toVec(L.A, A));
    if (k < 0) isNeg = true;
    if (k > 0) isPos = true;
  }
  if (!isNeg) return true;
  if (!isPos) return true;
  return false;
}
bool always[100010];
bool solve(int I, line L) {
  if (always[I]) return true;
  if (isOneSide(L)) return false;
  for (int i = (0); i <= (int((P).size()) - 1); i++) {
    point A = P[i], B = P[(i + 1) % int((P).size())];
    if (crossProduct(toVec(L.A, L.B), toVec(L.A, A)) == 0) {
      if (!check(A, L)) continue;
      g[I].push_back(A);
      continue;
    }
    if (crossProduct(toVec(L.A, L.B), toVec(L.A, A)) *
            crossProduct(toVec(L.A, L.B), toVec(L.A, B)) <
        0) {
      point p;
      areIntersect(line(A, B), L, p);
      if (!check(p, L)) continue;
      g[I].push_back(p);
    }
  }
  if (int((g[I]).size()) == 0) return false;
  if (int((g[I]).size()) == 1)
    if (!(L.A.x < topRight.x && L.A.x > botLeft.x && L.A.y < topRight.y &&
          L.A.y > botLeft.y))
      return false;
  return true;
}
bool f[100010];
int main() {
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  cin >> botLeft.x >> botLeft.y >> topRight.x >> topRight.y;
  P.push_back(botLeft);
  P.push_back(point(botLeft.x, topRight.y));
  P.push_back(topRight);
  P.push_back(point(topRight.x, botLeft.y));
  for (int i = (1); i <= (n); i++) {
    point p;
    cin >> p.x >> p.y;
    point v;
    cin >> v.x >> v.y;
    if (0 == v.x && 0 == v.y) {
      a.push_back(line(point(0, 0), point(1, 1)));
      if (p.x < topRight.x && p.x > botLeft.x && p.y < topRight.y &&
          p.y > botLeft.y)
        always[i - 1] = true;
      else {
        cout << -1;
        return 0;
      }
      continue;
    }
    v.x += p.x;
    v.y += p.y;
    a.push_back(line(p, v));
  }
  if (topRight.x == botLeft.x || topRight.y == botLeft.y) {
    cout << -1;
    return 0;
  }
  for (int i = (0); i <= (n - 1); i++)
    if (!solve(i, a[i])) {
      cout << -1;
      return 0;
    }
  for (int i = (0); i <= (n - 1); i++)
    if (int((g[i]).size()) == 1) {
      f[i] = true;
      g[i].push_back(a[i].A);
    }
  double lef = 0;
  double rig = 1000000000;
  for (int i = (0); i <= (n - 1); i++) {
    if (always[i]) continue;
    double u, t1, t2;
    if (a[i].B.x == a[i].A.x) {
      u = g[i][0].y - a[i].A.y;
      t1 = u / (a[i].B.y - a[i].A.y);
      u = g[i][1].y - a[i].A.y;
      t2 = u / (a[i].B.y - a[i].A.y);
    } else {
      u = g[i][0].x - a[i].A.x;
      t1 = u / (a[i].B.x - a[i].A.x);
      u = g[i][1].x - a[i].A.x;
      t2 = u / (a[i].B.x - a[i].A.x);
    }
    if (t1 > t2) swap(t1, t2);
    if (!f[i]) t1 += 1e-15;
    if (t2 != 0) t2 -= 1e-15;
    if (t1 > rig || t2 < lef) {
      cout << -1 << endl;
      return 0;
    }
    lef = max(lef, t1);
    rig = min(rig, t2);
  }
  cout << fixed << setprecision(9) << lef;
  return 0;
}
