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;
int fst[666666], nxt[666666], vb[666666], ff[666666], M = 1, N = 0;
long long cap[666666];
void _ad_dl(int a, int b, long long c) {
  ++M;
  nxt[M] = fst[a];
  fst[a] = M;
  vb[M] = b;
  cap[M] = c;
}
void ad_dl(int a, int b, long long c) {
  _ad_dl(a, b, c);
  _ad_dl(b, a, 0);
}
int S, T, q[666666], d_[666666];
bool bfs() {
  memset(d_, -1, 4 * (N + 1));
  d_[T] = 0;
  q[1] = T;
  int h = 1, t = 2;
  while (h != t) {
    int cur = q[h++];
    for (int e = fst[cur]; e; e = nxt[e]) {
      int b = vb[e];
      if (d_[b] == -1 && cap[e ^ 1]) {
        d_[b] = d_[cur] + 1, q[t++] = b;
        if (b == S) return 1;
      }
    }
  }
  return d_[S] != -1;
}
long long dfs(int x, long long f) {
  if (f <= 0) return 0;
  if (x == T) return f;
  long long ca = 0;
  for (int& e = fst[x]; e; e = nxt[e]) {
    int b = vb[e];
    if (d_[b] + 1 != d_[x]) continue;
    long long w = dfs(b, (cap[e] < f - ca) ? cap[e] : (f - ca));
    cap[e] -= w;
    cap[e ^ 1] += w;
    ca += w;
    if (ca == f) break;
  }
  if (!ca) d_[x] = -1;
  return ca;
}
long long dinic() {
  long long ans = 0;
  memcpy(ff, fst, 4 * (N + 1));
  while (bfs()) ans += dfs(S, 2e18), memcpy(fst, ff, 4 * (N + 1));
  return ans;
}
const long long G = 1.01e7;
int n, e, u[666666], v[666666], a[666666], b[666666], c[666666], d[666666];
long long ds[666666];
long long f(long long x) {
  for (int i = 1; i <= N; ++i) fst[i] = ds[i] = 0;
  N = n;
  S = ++N;
  T = ++N;
  M = 1;
  for (int i = 1; i <= e; ++i) {
    long long L = a[i] * x + b[i] * G, R = c[i] * x + d[i] * G;
    ad_dl(u[i], v[i], R - L);
    ds[v[i]] += L;
    ds[u[i]] -= L;
  }
  long long sb = 0;
  for (int i = 1; i <= N; ++i)
    if (ds[i] > 0)
      ad_dl(S, i, ds[i]), sb += ds[i];
    else if (ds[i] < 0)
      ad_dl(i, T, -ds[i]);
  long long aa = sb - dinic();
  return aa;
}
int main() {
  cin >> n >> e;
  for (int i = 1; i <= e; ++i)
    cin >> u[i] >> v[i] >> a[i] >> b[i] >> c[i] >> d[i];
  long long l = 0, r = G;
  while (r - l > 10) {
    long long m1 = l + (r - l) / 3, m2 = r - (r - l) / 3;
    if (f(m1) < f(m2))
      r = m2;
    else
      l = m1;
  }
  pair<long long, long long> mi(8e18, 8e18);
  for (long long t = l; t <= r; ++t) mi = min(mi, make_pair(f(t), t));
  if (mi.first) {
    puts("0");
    return 0;
  }
  l = mi.second, r = G;
  while (l < r) {
    long long m = (l + r + 1) >> 1;
    if (f(m))
      r = m - 1;
    else
      l = m;
  }
  long long ans = l;
  l = 0, r = mi.second;
  while (l < r) {
    long long m = (l + r) >> 1;
    if (f(m))
      l = m + 1;
    else
      r = m;
  }
  ans -= l;
  printf("%.10lf\n", ans / double(G));
}
