2 2
1 2 1 4 2 4
1 2 3 4 4 4
 2 2
1 2 0 9998 0 9999
2 1 0 9999 0 10000
 3 3
1 2 0 3 -4 7
2 3 -2 5 1 6
3 1 0 4 0 4
 2 2
1 2 0 3 0 3
2 1 0 4 0 4
 2 2
1 2 0 0 0 0
2 1 0 0 0 0
 5 10
4 3 -19 49 -11 65
4 4 50 12 -2 65
1 5 56 8 -5 76
5 1 -28 33 -38 49
4 2 0 0 2 9
4 2 0 0 14 8
3 1 26 67 15 85
5 3 -51 98 -44 99
1 3 -33 65 -20 65
3 4 30 6 -30 70
 5 10
4 3 -8 16 -29 72
4 4 -62 65 33 65
1 5 -58 97 -17 97
5 1 -5 10 -68 88
4 2 0 0 -9 60
4 2 0 0 -23 39
3 1 3 28 13 87
5 3 -1 25 -15 90
1 3 -12 33 6 94
3 4 -71 86 -39 86
 5 10
4 3 -1 5 -6 98
4 4 12 14 -43 98
1 5 -4 6 8 88
5 1 0 0 -9 100
4 2 0 0 6 50
4 2 0 0 -39 77
3 1 1 4 -1 100
5 3 -7 13 9 88
1 3 2 0 -7 100
3 4 2 0 3 88
 2 2
1 1 0 4 0 5
2 2 4 0 5 0
 2 2
1 2 0 4 0 4
2 1 0 4 0 4
 2 2
1 2 0 3 0 5
2 1 0 4 0 6

0
 1.0000000000
 0.2500000000
 0
 1.0000000000
 0.2121212000
 0.6666666000
 1.0000000000
 1.0000000000
 1.0000000000
 1.0000000000

#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
const int maxm = 2005;
int n, m;
int u[maxm], v[maxm], a[maxm], b[maxm], c[maxm], d[maxm];
namespace Flow {
const int maxv = maxn;
const int maxe = maxm * 3;
int S, T, V, tot;
int head[maxv], nxt[maxe << 1], to[maxe << 1];
double cap[maxe << 1];
int lvl[maxv], que[maxv], cur[maxv];
void init() {
  tot = 0;
  memset(head, -1, sizeof(head));
}
void addedge(int u, int v, double c) {
  nxt[tot] = head[u];
  to[tot] = v;
  cap[tot] = c;
  head[u] = tot++;
  nxt[tot] = head[v];
  to[tot] = u;
  cap[tot] = 0;
  head[v] = tot++;
}
bool bfs() {
  for (int i = 0; i < V; i++) lvl[i] = -1;
  lvl[S] = 0;
  int ql = 0, qr = 0;
  que[qr++] = S;
  while (ql < qr) {
    int x = que[ql++];
    for (int i = head[x]; ~i; i = nxt[i])
      if (cap[i] > 0 && lvl[to[i]] < 0) {
        lvl[to[i]] = lvl[x] + 1;
        que[qr++] = to[i];
      }
  }
  return lvl[T] >= 0;
}
double dfs(int x, double f) {
  if (x == T) return f;
  for (int &i = cur[x]; ~i; i = nxt[i])
    if (cap[i] > 0 && lvl[to[i]] == lvl[x] + 1) {
      double d = dfs(to[i], min(cap[i], f));
      if (d > 0) {
        cap[i] -= d;
        cap[i ^ 1] += d;
        return d;
      }
    }
  return 0;
}
double work() {
  double res = 0;
  while (bfs()) {
    for (int i = 0; i < V; i++) cur[i] = head[i];
    double f;
    while (f = dfs(S, 1e9)) res += f;
  }
  return res;
}
}  // namespace Flow
double calc(double t) {
  Flow::init();
  Flow::S = 0;
  Flow::T = n + 1;
  Flow::V = Flow::T + 2;
  double tot = 0;
  for (int i = 1; i <= m; i++) {
    double l = a[i] * t + b[i], r = c[i] * t + d[i];
    Flow::addedge(u[i], v[i], r - l);
    Flow::addedge(Flow::S, v[i], l);
    Flow::addedge(u[i], Flow::T, l);
    tot += l;
  }
  return Flow::work() - tot;
}
double findP(double l, double r) {
  while (r - l > 1e-8) {
    double midl = l + (r - l) / 3, midr = r - (r - l) / 3;
    double vall = calc(midl), valr = calc(midr);
    if (vall < valr)
      l = midl;
    else
      r = midr;
  }
  return (l + r) / 2;
}
double findL(double l, double r) {
  while (r - l > 1e-8) {
    double mid = (l + r) / 2;
    if (calc(mid) >= -1e-9)
      r = mid;
    else
      l = mid;
  }
  return (l + r) / 2;
}
double findR(double l, double r) {
  while (r - l > 1e-8) {
    double mid = (l + r) / 2;
    if (calc(mid) >= -1e-9)
      l = mid;
    else
      r = mid;
  }
  return (l + r) / 2;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++)
    scanf("%d%d%d%d%d%d", &u[i], &v[i], &a[i], &b[i], &c[i], &d[i]);
  double p = findP(0, 1);
  printf("%.10lf\n", findR(p, 1) - findL(0, p));
  return 0;
}
