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;
class MaxFlow {
 public:
  struct Edge {
    int b, e;
    long double f;
  } E[10100 * 2];
  vector<int> G[2010];
  int Level[2010], Q[2010], PV[2010], source, sink, EC, n;
  long double flow;
  void init(int N, int S, int T) {
    n = N, EC = 0;
    for (int i = 0; i <= n; i++) G[i].clear();
    flow = 0.0;
    source = S, sink = T;
  }
  void Add_Edge(int a, int b, long double f) {
    G[a].push_back(EC);
    G[b].push_back(EC + 1);
    E[EC++] = {a, b, f};
    E[EC++] = {b, a, 0.0};
  }
  bool GetLevel() {
    int i;
    for (i = 1; i <= n; i++) Level[i] = -1;
    int head = 0, tail = 0;
    Q[++tail] = source, Level[source] = 0;
    while (head < tail) {
      int x = Q[++head];
      for (auto &y : G[x]) {
        if (E[y].f > 0 && Level[E[y].e] == -1) {
          Q[++tail] = E[y].e;
          Level[E[y].e] = Level[x] + 1;
        }
      }
    }
    return Level[sink] != -1;
  }
  long double BlockFlow(int a, long double f) {
    if (a == sink) return f;
    long double M = 1e9;
    for (int &i = PV[a]; i >= 0; i--) {
      int x = G[a][i];
      if (E[x].f > 0 && Level[E[x].e] == Level[a] + 1) {
        long double t = BlockFlow(E[x].e, min(f, E[x].f));
        if (t) {
          E[x].f -= t;
          E[x ^ 1].f += t;
          return t;
        }
      }
    }
    return 0.0;
  }
  void Dinic() {
    long double t;
    while (GetLevel()) {
      for (int i = 1; i <= n; i++) PV[i] = G[i].size() - 1;
      while ((t = BlockFlow(source, 1e9)) > 0) flow += t;
    }
  }
} G1;
struct EdEd {
  int b, e, A, B, C, D;
} w[2010];
int n, m;
long double Calc(long double tt) {
  G1.init(n + 2, n + 1, n + 2);
  int i;
  long double sum = 0.0;
  for (i = 0; i < m; i++) {
    long double l = w[i].A * tt + w[i].B, r = w[i].C * tt + w[i].D;
    G1.Add_Edge(w[i].b, w[i].e, r - l);
    G1.Add_Edge(w[i].b, G1.sink, l);
    G1.Add_Edge(G1.source, w[i].e, l);
    sum += l;
  }
  G1.Dinic();
  return sum - G1.flow;
}
long double res;
void Make(long double b, long double e) {
  long double mid;
  for (int i = 0; i < 50; i++) {
    mid = (b + e) * 0.5;
    if (Calc(mid) < 1e-9) {
      long double tp = mid - b;
      res += (tp > 0 ? tp : -tp);
      b = mid;
    } else
      e = mid;
  }
}
int main() {
  int i;
  scanf("%d%d", &n, &m);
  for (i = 0; i < m; i++) {
    scanf("%d%d%d%d%d%d", &w[i].b, &w[i].e, &w[i].A, &w[i].B, &w[i].C, &w[i].D);
  }
  long double be = 0.0, ed = 1.0, m1, m2;
  for (int tt = 0; tt < 50; tt++) {
    m1 = (be * 2 + ed) / 3;
    m2 = (be + ed * 2) / 3;
    long double t1 = Calc(m1);
    long double t2 = Calc(m2);
    if (t1 < 1e-9 && t2 < 1e-9) {
      Make((m1 + m2) * 0.5, 0);
      Make((m1 + m2) * 0.5, 1);
      break;
    }
    if (t1 < t2)
      ed = m2;
    else
      be = m1;
  }
  printf("%.10Lf\n", res);
}
