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;
inline long long read() {
  char c = getchar();
  long long x = 0;
  bool f = 0;
  for (; !isdigit(c); c = getchar()) f ^= !(c ^ 45);
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  if (f) x = -x;
  return x;
}
const long long maxn = 2007, maxm = 4007, inf = 0x3f3f3f3f3f3f3f3f;
long long n, m, s, t, maxflow;
long long dep[maxn], cur[maxn], de[maxn];
long long tot = 1, head[maxn];
struct edge {
  long long to, nxt, w;
} e[maxm << 1];
inline void adde(long long u, long long v, long long w) {
  e[++tot] = (edge){v, head[u], w};
  head[u] = tot;
}
inline void add(long long u, long long v, long long w) {
  adde(u, v, w);
  adde(v, u, 0);
}
inline void ins(long long u, long long v, long long l, long long r) {
  add(u, v, r - l), de[u] -= l, de[v] += l;
}
bool bfs(long long s, long long t) {
  queue<long long> q;
  memcpy(cur, head, sizeof cur);
  memset(dep, 63, sizeof dep);
  dep[s] = 0;
  q.push(s);
  while (!q.empty()) {
    long long u = q.front();
    q.pop();
    for (long long i = head[u]; i; i = e[i].nxt) {
      long long v = e[i].to;
      if (dep[v] == inf && e[i].w) {
        dep[v] = dep[u] + 1;
        q.push(v);
      }
    }
  }
  return dep[t] < inf;
}
long long dfs(long long u, long long t, long long minn) {
  if (!minn || u == t) return minn;
  long long res = 0;
  for (long long i = cur[u]; i; i = e[i].nxt) {
    long long v = e[i].to;
    cur[u] = i;
    if (dep[v] != dep[u] + 1) continue;
    long long flow = dfs(v, t, min(minn, e[i].w));
    if (!flow) continue;
    res += flow, minn -= flow;
    e[i].w -= flow, e[i ^ 1].w += flow;
    if (!minn) break;
  }
  if (!res) dep[u] = 0;
  return res;
}
inline long long dinic(long long s, long long t) {
  long long maxflow = 0;
  while (bfs(s, t)) maxflow += dfs(s, t, inf);
  return maxflow;
}
long long a[maxn], b[maxn], c[maxn], d[maxn], uu[maxn], vv[maxn],
    lim = 100000000;
map<long long, long long> mp;
long long func(long long v) {
  if (mp.count(v)) return mp[v];
  for (register long long i = (1); i <= (n + 2); ++i) head[i] = de[i] = 0;
  s = n + 1, t = n + 2;
  tot = 1;
  for (register long long i = (1); i <= (m); ++i) {
    long long l = a[i] * v + b[i] * lim, r = c[i] * v + d[i] * lim;
    ins(uu[i], vv[i], l, r);
  }
  long long res = 0;
  for (register long long i = (1); i <= (n); ++i)
    if (de[i] > 0)
      add(s, i, de[i]), res += de[i];
    else
      add(i, t, -de[i]);
  return mp[v] = res - dinic(s, t);
}
signed main() {
  n = read(), m = read();
  for (register long long i = (1); i <= (m); ++i) {
    uu[i] = read(), vv[i] = read();
    a[i] = read(), b[i] = read(), c[i] = read(), d[i] = read();
  }
  func(75000004);
  long long l = 0, r = lim;
  while (r - l >= 5) {
    long long m1 = l + (r - l) / 3, m2 = r - (r - l) / 3;
    if (func(m1) < func(m2))
      r = m2;
    else
      l = m1;
  }
  pair<long long, long long> mg = make_pair(inf, inf);
  for (register long long i = (l); i <= (r); ++i)
    mg = min(mg, make_pair(func(i), i));
  if (mg.first) {
    puts("0");
    return 0;
  }
  l = mg.second + 1, r = lim;
  long long resl = mg.second, resr = mg.second;
  while (l <= r) {
    long long mid = l + r >> 1;
    if (!func(mid))
      resr = mid, l = mid + 1;
    else
      r = mid - 1;
  }
  l = 0, r = mg.second - 1;
  while (l <= r) {
    long long mid = l + r >> 1;
    if (!func(mid))
      resl = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  printf("%.8lf", 1.0 * (resr - resl) / lim);
  return 0;
}
