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>
template <typename Y>
inline bool updmin(Y &a, Y b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename Y>
inline bool updmax(Y &a, Y b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename Y>
inline Y abs(Y a) {
  if (a < 0) a = -a;
  return a;
}
template <typename Y>
inline Y sqr(Y a) {
  return a * a;
}
int read() {
  int w = 1, q = 0, ch = ' ';
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') w = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) q = q * 10 + ch - 48;
  return q * w;
}
inline void FileIO() {
  freopen(
      ""
      ".in",
      "r", stdin);
  freopen(
      ""
      ".out",
      "w", stdout);
}
const int maxn = 10080;
const long long M = 1e9;
int n, m, U[maxn], V[maxn];
long long a[maxn], b[maxn], c[maxn], d[maxn];
namespace fa {
const long long inf = 1ll << 60;
int e_num = 1, S, T;
int hed[maxn], dep[maxn];
long long deg[maxn];
struct Edge {
  int from, to, nxt;
  long long c;
} edge[maxn * 4];
void addedge(int from, int to, long long c) {
  edge[++e_num] = (Edge){from, to, hed[from], c};
  hed[from] = e_num;
}
void adde(int from, int to, long long c) {
  addedge(from, to, c);
  addedge(to, from, 0);
}
void clear() {
  e_num = 1;
  memset(hed, 0, sizeof hed);
}
std::queue<int> q;
bool bfs() {
  while (!q.empty()) {
    q.pop();
  }
  q.push(S);
  memset(dep, 0, sizeof(dep));
  dep[S] = 1;
  while (!q.empty()) {
    int cur = q.front();
    q.pop();
    for (int i = hed[cur]; i; i = edge[i].nxt) {
      int to = edge[i].to;
      if (!dep[to] && edge[i].c) {
        dep[to] = dep[cur] + 1;
        q.push(to);
      }
    }
  }
  return dep[T];
}
long long dfs(int x, long long flow) {
  if (x == T) return flow;
  long long ret = 0;
  for (int i = hed[x]; i; i = edge[i].nxt) {
    int to = edge[i].to;
    if (dep[to] == dep[x] + 1 && edge[i].c) {
      long long tmp = dfs(to, std::min(flow, edge[i].c));
      edge[i].c -= tmp;
      edge[i ^ 1].c += tmp;
      flow -= tmp;
      ret += tmp;
      if (!flow) {
        break;
      }
    }
  }
  if (!ret) dep[x] = 0;
  return ret;
}
long long dinic() {
  long long ret = 0;
  while (bfs()) {
    ret += dfs(S, inf);
  }
  return ret;
}
long long check(long long t) {
  long long suml = 0;
  clear();
  S = 0, T = n + 1;
  memset(deg, 0, sizeof deg);
  for (int i = 1; i <= m; i++) {
    long long l = a[i] * t + b[i];
    long long r = c[i] * t + d[i];
    deg[U[i]] -= l;
    deg[V[i]] += l;
    adde(U[i], V[i], r - l);
  }
  for (int i = 1; i <= n; i++) {
    if (deg[i] > 0) {
      suml += deg[i];
      adde(S, i, deg[i]);
    } else {
      adde(i, T, -deg[i]);
    }
  }
  long long d = dinic();
  return suml - d;
}
}  // namespace fa
long long L, R, ans1, ans2;
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= m; i++) {
    U[i] = read();
    V[i] = read();
    a[i] = read();
    b[i] = read() * M;
    c[i] = read();
    d[i] = read() * M;
  }
  L = 0, R = M;
  while (L < R) {
    long long mid = (L + R) >> 1;
    long long delta = fa::check(mid + 1) - fa::check(mid);
    if (delta >= 0) {
      R = mid;
    } else {
      L = mid + 1;
    }
  }
  ans1 = L;
  if (fa::check(ans1) != 0) {
    puts("0");
    return 0;
  }
  L = 0, R = M;
  while (L < R) {
    long long mid = (L + R + 1) >> 1;
    long long delta = fa::check(mid) - fa::check(mid - 1);
    if (delta <= 0) {
      L = mid;
    } else {
      R = mid - 1;
    }
  }
  ans2 = R;
  printf("%.10lf\n", (double)(ans2 - ans1) / (double)M);
  return 0;
}
