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>
const double eps = 1e-11;
const int maxn = 1010, maxm = 2010;
int n, m, u[maxm], v[maxm], a[maxm], b[maxm], c[maxm], d[maxm];
struct edge {
  int to;
  double cap;
  edge *rev, *next;
} E[maxm * 2 + maxn * 4], *ne, *fir[maxn], *cur[maxn];
void link(int a, int b, double c) {
  *ne = (edge){b, c, ne + 1, fir[a]};
  fir[a] = ne++;
  *ne = (edge){a, 0, ne - 1, fir[b]};
  fir[b] = ne++;
}
int Q[maxn], D[maxn];
double dfs(int i, double c) {
  if (i == 1 || c < eps) return c;
  double fl = 0, f;
  for (edge*& e = cur[i]; e && c >= eps; e = e->next)
    if (e->cap >= eps && D[e->to] == D[i] - 1)
      fl += f = dfs(e->to, c < e->cap ? c : e->cap), e->cap -= f,
            e->rev->cap += f, c -= f;
  return fl;
}
double mf() {
  for (double f = 0;; f += dfs(0, 1e18)) {
    for (int i = 0; i <= n + 1; i++) D[i] = 0, cur[i] = fir[i];
    for (int *h = Q, *t = Q + (D[*Q = 1] = 1); h < t; h++)
      for (edge* e = fir[*h]; e; e = e->next)
        if (e->rev->cap >= eps && !D[e->to]) D[*t++ = e->to] = D[*h] + 1;
    if (!*D) return f;
  }
}
int da[maxn];
double de[maxn];
int chk(double t) {
  ne = E;
  for (int i = 0; i <= n + 1; i++) fir[i] = 0, da[i] = 0, de[i] = 0;
  for (int i = 0; i < m; i++) {
    link(u[i] + 1, v[i] + 1, (c[i] - a[i]) * t + d[i] - b[i]);
    double x = a[i] * t + b[i];
    da[u[i]] -= a[i];
    da[v[i]] += a[i];
    de[u[i]] -= x;
    de[v[i]] += x;
  }
  double s = 0;
  for (int i = 1; i <= n; i++) {
    if (de[i] > 0)
      link(0, i + 1, de[i]), s += de[i];
    else
      link(i + 1, 1, -de[i]);
  }
  if (mf() < s - 1e-8) {
    int sa = 0;
    for (int i = 1; i <= n; i++) D[i + 1] ? sa += da[i] : 1;
    for (int i = 0; i < m; i++)
      !D[u[i] + 1] && D[v[i] + 1] ? sa += c[i] - a[i] : 1;
    return sa > 0 ? -1 : 1;
  }
  return 0;
}
double solve(double l, double r, int lv, int rv) {
  double mid;
  while (r - l > 1e-8) {
    int t = chk(mid = (l + r) / 2);
    if (t == lv)
      l = mid;
    else if (t == rv)
      r = mid;
    else
      return solve(mid, r, 0, 1) - solve(l, mid, -1, 0);
  }
  return lv < 0 && rv > 0 ? 0 : r;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++)
    scanf("%d%d%d%d%d%d", u + i, v + i, a + i, b + i, c + i, d + i);
  printf("%.7lf\n", solve(0, 1, -1, 1));
}
