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 long long M = (long long)1e9;
struct edge {
  int r, nxt;
  long long w;
} e[10010 << 1];
long long deg[10010], a[10010], b[10010], c[10010], d[10010];
int fr[10010], to[10010], n, m;
int q[10010], l, r, cur[10010], dep[10010], head[10010], esz, S, T;
void addedge(int u, int v, long long w) {
  e[++esz].r = v;
  e[esz].nxt = head[u];
  head[u] = esz;
  e[esz].w = w;
  e[++esz].r = u;
  e[esz].nxt = head[v];
  head[v] = esz;
  e[esz].w = 0;
}
bool bfs() {
  for (int i = S; i <= T; ++i) cur[i] = head[i], dep[i] = 0;
  l = r = 0, q[r++] = S, dep[S] = 1;
  while (l < r) {
    int u = q[l++];
    for (int t = head[u]; t; t = e[t].nxt)
      if (e[t].w && !dep[e[t].r]) dep[e[t].r] = dep[u] + 1, q[r++] = e[t].r;
  }
  return dep[T] != 0;
}
long long find(int u, long long flow) {
  if (u == T) return flow;
  long long used = 0, a = 0;
  for (int& t = cur[u]; t; t = e[t].nxt)
    if (e[t].w && dep[e[t].r] == dep[u] + 1) {
      a = find(e[t].r, min(flow - used, e[t].w));
      used += a, e[t].w -= a, e[t ^ 1].w += a;
      if (flow == used) return used;
    }
  return used;
}
long long dinic() {
  long long ans = 0, a;
  while (bfs()) ans += find(S, 1ll << 60);
  return ans;
}
long long sol(long long t) {
  long long sum = 0;
  esz = 1, S = 0, T = n + 1;
  for (int i = S; i <= T; ++i) head[i] = deg[i] = 0;
  for (int i = 1; i <= m; ++i) {
    long long l = a[i] * t + b[i], r = c[i] * t + d[i];
    deg[to[i]] += l;
    deg[fr[i]] -= l;
    addedge(fr[i], to[i], r - l);
  }
  for (int i = 1; i <= n; ++i)
    if (deg[i] > 0)
      sum += deg[i], addedge(S, i, deg[i]);
    else
      addedge(i, T, -deg[i]);
  return sum - dinic();
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d%lld%lld%lld%lld", &fr[i], &to[i], &a[i], &b[i], &c[i], &d[i]);
    b[i] *= M, d[i] *= M;
  }
  long long l = 0, r = M;
  for (int i = 0; r - l > 3; ++i) {
    long long mid1 = (l + l + r) / 3, mid2 = (l + r + r) / 3;
    long long f1 = sol(mid1), f2 = sol(mid2);
    if (f1 > f2)
      l = mid1;
    else
      r = mid2;
  }
  long long l1 = 0, r1 = l;
  for (int i = 0; l1 < r1; ++i) {
    long long mid = (l1 + r1) / 2;
    if (sol(mid) == 0)
      r1 = mid;
    else
      l1 = mid + 1;
  }
  long long l2 = l, r2 = M;
  for (int i = 0; l2 < r2; ++i) {
    long long mid = (l2 + r2) / 2;
    if (sol(mid) == 0)
      l2 = mid + 1;
    else
      r2 = mid;
  }
  printf("%.10lf", (double)(l2 - l1) / (double)M);
}
