#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
const int maxm = 2005;
const long double eps = 1e-9;
int n, m;
int u[maxm], v[maxm], a[maxm], b[maxm], c[maxm], d[maxm];
namespace Flow {
const int maxv = maxn;
const int maxe = maxm * 3;
int S, T, V, tot;
int head[maxv], nxt[maxe << 1], to[maxe << 1];
long double cap[maxe << 1];
int lvl[maxv], que[maxv], cur[maxv];
void init() {
  tot = 0;
  memset(head, -1, sizeof(head));
}
void addedge(int u, int v, double c) {
  nxt[tot] = head[u];
  to[tot] = v;
  cap[tot] = c;
  head[u] = tot++;
  nxt[tot] = head[v];
  to[tot] = u;
  cap[tot] = 0;
  head[v] = tot++;
}
bool bfs() {
  for (int i = 0; i < V; i++) lvl[i] = -1;
  lvl[S] = 0;
  int ql = 0, qr = 0;
  que[qr++] = S;
  while (ql < qr) {
    int x = que[ql++];
    for (int i = head[x]; ~i; i = nxt[i])
      if (cap[i] > eps && lvl[to[i]] < 0) {
        lvl[to[i]] = lvl[x] + 1;
        que[qr++] = to[i];
      }
  }
  return lvl[T] >= 0;
}
long double dfs(int x, long double f) {
  if (x == T) return f;
  for (int &i = cur[x]; ~i; i = nxt[i])
    if (cap[i] > eps && lvl[to[i]] == lvl[x] + 1) {
      long double d = dfs(to[i], min(cap[i], f));
      if (d > eps) {
        cap[i] -= d;
        cap[i ^ 1] += d;
        return d;
      }
    }
  return 0;
}
long double work() {
  long double res = 0;
  while (bfs()) {
    for (int i = 0; i < V; i++) cur[i] = head[i];
    long double f;
    while ((f = dfs(S, 1e9)) > eps) res += f;
  }
  return res;
}
}  // namespace Flow
long double calc(long double t) {
  Flow::init();
  Flow::S = 0;
  Flow::T = n + 1;
  Flow::V = Flow::T + 2;
  long double tot = 0;
  for (int i = 1; i <= m; i++) {
    long double l = a[i] * t + b[i], r = c[i] * t + d[i];
    Flow::addedge(u[i], v[i], r - l);
    Flow::addedge(Flow::S, v[i], l);
    Flow::addedge(u[i], Flow::T, l);
    tot += l;
  }
  return Flow::work() - tot;
}
long double findP(long double l, long double r) {
  while (r - l > 1e-8) {
    long double midl = l + (r - l) / 3, midr = r - (r - l) / 3;
    long double vall = calc(midl), valr = calc(midr);
    if (vall < valr)
      l = midl;
    else
      r = midr;
  }
  return l;
}
long double findL(long double l, long double r) {
  while (r - l > 1e-8) {
    long double mid = (l + r) / 2;
    if (calc(mid) > -eps)
      r = mid;
    else
      l = mid;
  }
  return r;
}
long double findR(long double l, long double r) {
  while (r - l > 1e-8) {
    long double mid = (l + r) / 2;
    if (calc(mid) > -eps)
      l = mid;
    else
      r = mid;
  }
  return l;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++)
    scanf("%d%d%d%d%d%d", &u[i], &v[i], &a[i], &b[i], &c[i], &d[i]);
  long double p = findP(0, 1);
  printf("%.10lf\n", double(findR(p, 1) - findL(0, p)));
  return 0;
}
