#include <bits/stdc++.h>

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

typedef double db;
const db EPS = 1e-9;
const db inf=1e20;
inline int sign(db a) { return a < -EPS ? -1 : a > EPS; }
inline int cmp(db a, db b){ return sign(a-b); }

const int N=101000;
int ts,u[N],v[N],a[N],b[N],c[N],d[N],n,m;
typedef db flowt;
namespace flow {
	const int M=101000,N=101000;
	int y[M],nxt[M],gap[N],fst[N],c[N],pre[N],q[N],dis[N];
	int slope[M];
	flowt f[M];
	int S,T,tot,Tn;
	void init(int s,int t,int tn) {
		tot=1;
		memset(fst,0,sizeof(fst));
		S=s;T=t;Tn=tn;
	}
	void add(int u,int v,int c,flowt c1,flowt c2=0) {
		tot++;y[tot]=v;f[tot]=c1;nxt[tot]=fst[u];fst[u]=tot;
		slope[tot]=c;
		tot++;y[tot]=u;f[tot]=c2;nxt[tot]=fst[v];fst[v]=tot;
		slope[tot]=0;
	}
	flowt sap() {
		int u=S,t=1;flowt flow=0;
		rep(i,0,Tn) c[i]=fst[i],dis[i]=Tn,gap[i]=0;
		q[0]=T;dis[T]=0;pre[S]=0;
		rep(i,0,t) {
			int u=q[i];
			for (int j=fst[u];j;j=nxt[j]) if (dis[y[j]]>dis[u]+1&&fabs(f[j^1])>EPS)
				q[t++]=y[j],dis[y[j]]=dis[u]+1;
		}
		rep(i,0,Tn) gap[dis[i]]++;
		while (dis[S]<=Tn) {
			while (c[u]&&(fabs(f[c[u]])<EPS||dis[y[c[u]]]+1!=dis[u])) c[u]=nxt[c[u]];
			if (c[u]) {
				pre[y[c[u]]]=c[u]^1;
				u=y[c[u]];
				if (u==T) {
					flowt minf=inf;
					for (int p=pre[T];p;p=pre[y[p]]) minf=min(minf,f[p^1]);
					for (int p=pre[T];p;p=pre[y[p]]) f[p^1]-=minf,f[p]+=minf;
					flow+=minf;u=S;
				}
			} else {
				if (!(--gap[dis[u]])) break;
				int mind=Tn;
				c[u]=fst[u];
				for (int j=fst[u];j;j=nxt[j]) if (fabs(f[j])>EPS&&dis[y[j]]<mind)
					mind=dis[y[j]],c[u]=j;
				dis[u]=mind+1;
				gap[dis[u]]++;
				if (u!=S) u=y[pre[u]];
			}
		}
		q[0]=S; t=1;
		rep(i,0,Tn) dis[i]=Tn;
		dis[S]=0;
		rep(i,0,t) {
			int u=q[i];
			for (int j=fst[u];j;j=nxt[j]) if (dis[y[j]]>dis[u]+1&&fabs(f[j])>EPS) {
				dis[y[j]]=dis[u]+1;
				q[t++]=y[j];
			}
		}
		ts=0;
		rep(i,0,Tn) for (int j=fst[i];j;j=nxt[j]) if (dis[i]<Tn&&dis[y[j]]>=Tn) ts+=slope[j];
		return flow;
	}
};

db bel[N];
int sl[N];
int check(double t) {
	rep(i,1,n+1) bel[i]=0,sl[i]=0;
	flow::init(0,n+1,n+2);
	rep(i,0,m) {
		db l=a[i]*t+b[i],r=c[i]*t+d[i];
		flow::add(u[i],v[i],c[i]-a[i],r-l);
		bel[u[i]]+=l; bel[v[i]]-=l;
		sl[u[i]]+=a[i]; sl[v[i]]-=a[i];
	}
	db sf=0;
	int ss=0;
	rep(i,1,n+1) if (bel[i]>0) {
		sf+=bel[i]; flow::add(i,n+1,sl[i],bel[i]);
		ss+=sl[i];
	} else flow::add(0,i,-sl[i],-bel[i]);
	db r=flow::sap();
	if (ts==ss) {
		if (cmp(r,sf)==-1) return 2;
		else return 1;
	} else if (ts>ss) return 0;
	else return 2;
}
double gao(int ty) {
	double l=0,r=1;
	while (clock()<0.85*ty*CLOCKS_PER_SEC) {
		double md=(l+r)*0.5;
		if (check(md)>=ty) r=md; else l=md;
	}
	return 0.5*(l+r);
}
int main() {
	scanf("%d%d",&n,&m);
	rep(i,0,m) scanf("%d%d%d%d%d%d",u+i,v+i,a+i,b+i,c+i,d+i);
	db l=gao(1),r=gao(2);
	printf("%.10f\n",r-l);
}

#include<bits/stdc++.h>
#define MN 2000
#define S 0
#define T 1001
#define eps 1e-11
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
long double d[T+5],in[T+5];
int n,m,q[T+5],head[T+5],cnt,top,c[T+5];
struct Edge{
	int u,v,a,b,c,d;
}s[MN+5];
struct edge{
	int to,next;
	long double w;
}e[100005];
inline void ins(int f,int t,long double w)
{
   	e[++cnt]=(edge){t,head[f],w};head[f]=cnt;
   	e[++cnt]=(edge){f,head[t],0};head[t]=cnt;
}
inline bool bfs()
{
   	for(int i=1;i<=T;++i) d[i]=1e9;int i,j;
   	for(d[q[top=i=1]=S]=0;i<=top;++i)for(j=c[q[i]]=head[q[i]];j;j=e[j].next)if(e[j].w>eps&&d[q[i]]+1<d[e[j].to])d[q[++top]=e[j].to]=d[q[i]]+1;
   	return d[T]<1e8;
}
inline long double dfs(int x,long double f)
{
   	if(x==T) return f;long double used=0;
   	for(int&i=c[x];i;i=e[i].next)
    if(e[i].w>eps&&d[e[i].to]==d[x]+1)
    {
    	long double w=dfs(e[i].to,min(f-used,e[i].w));
    	used+=w;e[i].w-=w;e[i^1].w+=w;
    	if(f-used<eps) return f;
    }
   	return used;
}
inline long double Solve(long double t)
{
   	cnt=1;
	memset(head,0,sizeof(head));
   	memset(in,0,sizeof(in));
   	for(int i=1;i<=m;++i)
   	{
   		long double l=t*s[i].a+s[i].b,r=t*s[i].c+s[i].d;
   		ins(s[i].u,s[i].v,r-l);
   		in[s[i].v]+=l;
		in[s[i].u]-=l;
   	}
   	long double res=0;
   	for(int i=1;i<=n;++i) if(in[i]>0) res+=in[i],ins(S,i,in[i]);else ins(i,T,-in[i]);
    while(bfs()) res-=dfs(S,1e9);
    return res;
}
int main(void)
{
   	n=read();m=read();
   	for(int i=1;i<=m;++i) s[i].u=read(),s[i].v=read(),s[i].a=read(),s[i].b=read(),s[i].c=read(),s[i].d=read();
   	long double l=0,r=1,ok=-1;
   	for(int i=1;i<=50;++i)
   	{
   		long double m1=l+(r-l)/3,m2=m1+(r-l)/3;
   		long double r1=Solve(m1),r2=Solve(m2);
   		if(r1<eps){ok=m1;break;}
   		if(r2<eps){ok=m2;break;}
   		if(r1<r2) r=m2;
		else l=m1;
   	}
   	if(ok<0) return 0*puts("0");
   	l=0,r=ok;
	long double L=ok,R=ok;
   	for(int i=1;i<=50;++i)
   	{
   		long double mid=(l+r)*0.5;
   		if(Solve(mid)<eps) L=mid,r=mid;
   		else l=mid;
   	}
   	l=ok;r=1;
   	for(int i=1;i<=50;++i)
   	{
    	long double mid=(l+r)*0.5;
    	if(Solve(mid)<eps) R=mid,l=mid;
    	else r=mid;
    }
   	printf("%.10lf\n",(double)(R-L));
    return 0;
}

#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef double ld;
typedef unsigned long long ull;

using namespace std;

const ld eps = 1e-11;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

template<typename T>
struct Dinic {
	const T INF = 1e9;
	const int INF1 = 1e9;
	struct edge {
		int a, b;
		T f, c;
	};
	int s, t;
	vector<edge> ed;
	int n;
	vector<vector<int> > eds;
	vector<T> dd;
	vector<int> pp;
	vector<int> inCut;
	Dinic(int N, int S, int TT) {
		n = N, s = S, t = TT;
		eds.clear();
		dd.clear();
		pp.clear();
		ed.clear();
		eds.resize(n);
		dd.resize(n);
		pp.resize(n);
		inCut.clear();
	}
	void add_edge(int a, int b, T c) {
		edge x;
		x.a = a;
		x.b = b;
		x.f = 0;
		x.c = c;
		eds[a].push_back(ed.size());
		eds[b].push_back(ed.size() + 1);
		ed.push_back(x);
		x.c = 0;
		swap(x.a, x.b);
		ed.push_back(x);
	}
	T dfs(int v, T fl) {
		if (v == t)
			return fl;
		if (dd[v] == dd[t])
			return 0;
		T sum = 0;
		for (; pp[v] < (int)eds[v].size(); ++pp[v]) {
			int e = eds[v][pp[v]];
			int u = ed[e].b;
			T fr = ed[e].c - ed[e].f;
			if (fr <= eps || dd[u] != dd[v] + 1 || pp[u] == (int)eds[u].size())
				continue;
			fr = dfs(u, min(fl, fr));
			ed[e].f += fr;
			ed[e ^ 1].f -= fr;
			sum += fr;
			fl -= fr;
			if (fl <= eps)
				break;
		}
		return sum;
	}
	T flow() {
		T sum = 0;
		T lst = 0;
		do {
			lst = 0;
			fill(dd.begin(), dd.end(), INF1);
			dd[s] = 0;
			queue<int> qu;
			qu.push(s);
			while (!qu.empty()) {
				int x = qu.front();
				qu.pop();
				for (int i = 0; i < (int)eds[x].size(); ++i) {
					if (ed[eds[x][i]].f < ed[eds[x][i]].c) {
						int u = ed[eds[x][i]].b;
						if (dd[u] > dd[x] + 1)
							dd[u] = dd[x] + 1, qu.push(u);
					}
				}
			}
			if (dd[t] == INF)
				break;
			fill(pp.begin(), pp.end(), 0);
			lst = dfs(s, INF);
			sum += lst;
		} while (lst > 0);
		return sum;
	}
	void dfs1(int s) {
		pp[s] = 1;
		for (int e: eds[s]) {
			if (abs(ed[e].c - ed[e].f) > eps && !pp[ed[e].b])
				dfs1(ed[e].b);
		}
	}
	void markCut() {
		inCut.resize(ed.size());
		fill(pp.begin(), pp.end(), 0);
		dfs1(s);
		for (int i = 0; i < ed.size(); ++i)
			if (pp[ed[i].a] && !pp[ed[i].b])
				inCut[i] = 1;
			else
				inCut[i] = 0;
	}
};

int n, m;

vector<tuple<int, int, ll, ll> > edd;
vector<tuple<int, int, ll, ll, ll, ll> > edd2;
pair<ll, ll> ad[1200];
const int IT = 50;

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cout.setf(ios::fixed), cout.precision(20);
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int u, v;
		ll a, b, c, d;
		cin >> u >> v >> a >> b >> c >> d;
		--u, --v;
		edd.push_back(make_tuple(u, v, c - a, d - b));
		edd2.push_back(make_tuple(u, v, a, b, c, d));
		ad[u].first -= a;
		ad[u].second -= b;
		ad[v].first += a;
		ad[v].second += b;
	}
	ld lb = 0;
	ld rb = 1;
	ld ans = -1;
	for (int it = 0; it < IT; ++it) {
		ld mid = (lb + rb) / 2;
		Dinic<ld> din(n + 2, n, n + 1);
		for (auto x: edd) {
			int u, v;
			ll a, b;
			tie(u, v, a, b) = x;
			din.add_edge(u, v, a * mid + b);
		}
		ld go = 0;
		for (int i = 0; i < n; ++i) {
			ld x = ad[i].first * mid + ad[i].second;
			if (x > 0) {
				din.add_edge(n, i, x);
				go += x;
			}
			else if (x < 0) {
				din.add_edge(i, n + 1, -x);
			}
		}
		ld xx = din.flow();
		if (abs(xx - go) <= eps) {
			ans = mid;
			break;
		}
		din.markCut();
		pair<ld, ld> cur = make_pair(0, 0);
		for (auto x: edd2) {
			int u, v;
			ll a, b, c, d;
			tie(u, v, a, b, c, d) = x;
			if (din.pp[u] && !din.pp[v]) {
				cur.first += c;
				cur.second += d;
			}
			else if (din.pp[v] && !din.pp[u]) {
				cur.first -= a;
				cur.second -= b;
			}
		}
		if (cur.first == 0)
			break;
		if (cur.first > 0)
			lb = mid;
		else
			rb = mid;
	}
	if (ans < -0.5) {
		cout << 0 << "\n";
		return 0;
	}
	lb = 0;
	rb = ans;
	for (int it = 0; it < IT; ++it) {
		ld mid = (lb + rb) / 2;
		Dinic<ld> din(n + 2, n, n + 1);
		for (auto x: edd) {
			int u, v;
			ll a, b;
			tie(u, v, a, b) = x;
			din.add_edge(u, v, a * mid + b);
		}
		ld go = 0;
		for (int i = 0; i < n; ++i) {
			ld x = ad[i].first * mid + ad[i].second;
			if (x > 0) {
				din.add_edge(n, i, x);
				go += x;
			}
			else if (x < 0) {
				din.add_edge(i, n + 1, -x);
			}
		}
		ld xx = din.flow();
		if (abs(xx - go) <= eps)
			rb = mid;
		else
			lb = mid;
	}
	ld l = (lb + rb) / 2;
	lb = ans;
	rb = 1;
	for (int it = 0; it < IT; ++it) {
		ld mid = (lb + rb) / 2;
		Dinic<ld> din(n + 2, n, n + 1);
		for (auto x: edd) {
			int u, v;
			ll a, b;
			tie(u, v, a, b) = x;
			din.add_edge(u, v, a * mid + b);
		}
		ld go = 0;
		for (int i = 0; i < n; ++i) {
			ld x = ad[i].first * mid + ad[i].second;
			if (x > 0) {
				din.add_edge(n, i, x);
				go += x;
			}
			else if (x < 0) {
				din.add_edge(i, n + 1, -x);
			}
		}
		ld xx = din.flow();
		if (abs(xx - go) <= eps)
			lb = mid;
		else
			rb = mid;
	}
	ld r = (lb + rb) / 2;
	cout << r - l << "\n";
	return 0;
}

#include<cstdio>
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));
}
//hello

#include <bits/stdc++.h>
using namespace std;

const int NMAX = 1005;
const int MMAX = 2005;

const double EPS = 1e-7;

template <class CapacityType>
class MaxFlow {
private:
    static constexpr int NIL = -1;
    static constexpr double EPS = 1e-7;

    static constexpr int INF =
    std::numeric_limits<int> :: max() / 2;

    template <class type>
    int cmp(type x) {
        if (-EPS < x and x < EPS)
            return 0;
        return x < 0 ? -1 : 1;
    }

    struct Edge {
        int nod, nxt;
        CapacityType cap;

        Edge() :
        nod(0), nxt(0), cap(0) {};
        Edge(int _nod, int _nxt, CapacityType _cap) :
        nod(_nod), nxt(_nxt), cap(_cap) {};
    }; std::vector<Edge> lst;

    std::vector<bool> oki; int ptr = 0;
    std::vector<int> beg, que, adj, dis;

    bool bfs(const int src, const int dst) {
        std::fill(dis.begin(), dis.end(), (CapacityType)INF);
        dis[src] = 0; que[0] = src;

        for (int qbg = 0, qen = 0; qbg <= qen; ++qbg) {
            const int x = que[qbg];

            for (int it = beg[x]; it != NIL; it = lst[it].nxt) {
                const int y = lst[it].nod;

                if (cmp(lst[it].cap) > 0 and dis[y] == INF)
                    dis[y] = dis[x] + 1, que[++qen] = y;
            }
        }

        return dis[dst] != INF;
    }

    CapacityType dfs(const int x, const int dst, const CapacityType cap) {
        if (!cmp(cap) or x == dst)
            return cap;

        for (; adj[x] != NIL; adj[x] = lst[adj[x]].nxt) {
            const int y = lst[adj[x]].nod;

            if (cmp(lst[adj[x]].cap) > 0 and dis[y] == dis[x] + 1) {
                const CapacityType aux = dfs(y, dst, std::min(cap, lst[adj[x]].cap));

                if (cmp(aux)) {
                    lst[adj[x]].cap -= aux;
                    lst[adj[x] ^ 1].cap += aux;
                    return aux;
                }
            }
        }

        return 0;
    }

    void fill(const int x) {
        oki[x] = true;

        for (int it = beg[x]; it != NIL; it = lst[it].nxt) {
            const int y = lst[it].nod;

            if (cmp(lst[it].cap) > 0 and !oki[y])
                fill(y);
        }
    }
public:
    MaxFlow(int szn, int szm) {
        dis.resize(szn); beg.resize(szn);
        que.resize(szn); adj.resize(szn);
        oki.resize(szn); lst.resize(szm); // m != n

        std::fill(beg.begin(), beg.end(), (int)NIL);
    }

    inline void addDirectedEdge(const int x, const int y, const CapacityType cap) {
        lst[ptr] = Edge(y, beg[x], cap); beg[x] = ptr++;
        lst[ptr] = Edge(x, beg[y],  0 ); beg[y] = ptr++;
    }

    inline void addUndirectedEdge(const int x, const int y, const CapacityType cap) {
        lst[ptr] = Edge(y, beg[x], cap); beg[x] = ptr++;
        lst[ptr] = Edge(x, beg[y], cap); beg[y] = ptr++;
    }

    CapacityType getMaxFlow(const int src, const int dst) {
        CapacityType aux, ans = 0;

        while (bfs(src, dst)) {
            copy(beg.begin(), beg.end(), adj.begin());

            do {
                aux = dfs(src, dst, INF);
                ans += aux;
            } while (cmp(aux));
        }

        return ans;
    }

    CapacityType getMinCut(const int src, const int dst, std::vector<int> &ans) {
        std::fill(oki.begin(), oki.end(), false);
        CapacityType sol = getMaxFlow(src, dst); fill(src);

        ans.clear();
        for (int i = 0; i < oki.size(); ++i)
            if (oki[i]) ans.push_back(i);

        return sol;
    }
};

struct edge {
    int x, y, a, b, c, d; } edl[MMAX];

inline double sign(double x)
{
    if (-EPS < x and x < +EPS)
        return 0;
    return x < 0 ? -1 : 1;
}

double check(double t, int n, int m)
{
    int src = n + 1, dst = n + 2; double sum = 0;
    MaxFlow<double> myNetwork(n + 5, m * 6 + 5);

    for (int i = 1; i <= m; ++i) {
        int x = edl[i].x, y = edl[i].y;
        double le = t * edl[i].a + edl[i].b,
                    ri = t * edl[i].c + edl[i].d;

        sum += le;
        myNetwork.addDirectedEdge(x, y, ri - le);
        myNetwork.addDirectedEdge(src, y, le);
        myNetwork.addDirectedEdge(x, dst, le);
    }

    return sum - myNetwork.getMaxFlow(src, dst);
}

double solve(double le, double ri, int n, int m)
{
    double ans = 0;
    for (int i = 1; i <= 50; ++i) {
        double md = (le + ri) / 2.0;

        if (sign(check(md, n, m)) <= 0) {
            ans += fabs(md - le);
            le = md;
        } else
            ri = md;
    }
    return ans;
}

void debug(void)
{
    MaxFlow<double> myNetwork(4, 6);

    myNetwork.addDirectedEdge(1, 2, 0.5);
    myNetwork.addDirectedEdge(2, 3, 0.3);

    cerr << myNetwork.getMaxFlow(1, 3);

    exit(0);
}

int main(void)
{
   // freopen("test.in", "r", stdin);
   // freopen("test.out", "w", stdout);

    // debug();

    int n, m;
    cin >> n >> m;

    for (int i = 1; i <= m; ++i) {
        cin >> edl[i].x >> edl[i].y;
        cin >> edl[i].a >> edl[i].b >> edl[i].c >> edl[i].d;
    }

    /*
    for (double x = 0.0; x <= 1.00001; x += 0.05) {
        cout << setprecision(2) << fixed << x << " ";
        cout << setprecision(10) << fixed << check(x, n, m) << endl;
    }
    */

    double le = 0.0, ri = 1.0;
    for (int i = 1; i <= 50; ++i) {
        double md1 = le + (ri - le) / 3.0,
        md2 = ri - (ri - le) / 3.0;

        double ans1 = check(md1, n, m),
        ans2 = check(md2, n, m);

        if (sign(ans1) <= 0 and sign(ans2) <= 0) {
            cout << setprecision(10) << fixed;
            cout << solve((md1 + md2) / 2.0, 1.0, n, m) + solve((md1 + md2) / 2.0, 0.0, n, m);
            exit(0);
        }

        if (ans1 < ans2) ri = md2;
        else             le = md1;
    }

    cout << setprecision(10) << fixed << 0.0;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

typedef double db;
const db EPS = 1e-9;
const db inf=1e20;
inline int sign(db a) { return a < -EPS ? -1 : a > EPS; }
inline int cmp(db a, db b){ return sign(a-b); }

const int N=101000;
int ts,u[N],v[N],a[N],b[N],c[N],d[N],n,m;
typedef db flowt;
namespace flow {
	const int M=101000,N=101000;
	int y[M],nxt[M],gap[N],fst[N],c[N],pre[N],q[N],dis[N];
	int slope[M];
	flowt f[M];
	int S,T,tot,Tn;
	void init(int s,int t,int tn) {
		tot=1;
		memset(fst,0,sizeof(fst));
		S=s;T=t;Tn=tn;
	}
	void add(int u,int v,int c,flowt c1,flowt c2=0) {
		tot++;y[tot]=v;f[tot]=c1;nxt[tot]=fst[u];fst[u]=tot;
		slope[tot]=c;
		tot++;y[tot]=u;f[tot]=c2;nxt[tot]=fst[v];fst[v]=tot;
		slope[tot]=0;
	}
	flowt sap() {
		int u=S,t=1;flowt flow=0;
		rep(i,0,Tn) c[i]=fst[i],dis[i]=Tn,gap[i]=0;
		q[0]=T;dis[T]=0;pre[S]=0;
		rep(i,0,t) {
			int u=q[i];
			for (int j=fst[u];j;j=nxt[j]) if (dis[y[j]]>dis[u]+1&&fabs(f[j^1])>EPS)
				q[t++]=y[j],dis[y[j]]=dis[u]+1;
		}
		rep(i,0,Tn) gap[dis[i]]++;
		while (dis[S]<=Tn) {
			while (c[u]&&(fabs(f[c[u]])<EPS||dis[y[c[u]]]+1!=dis[u])) c[u]=nxt[c[u]];
			if (c[u]) {
				pre[y[c[u]]]=c[u]^1;
				u=y[c[u]];
				if (u==T) {
					flowt minf=inf;
					for (int p=pre[T];p;p=pre[y[p]]) minf=min(minf,f[p^1]);
					for (int p=pre[T];p;p=pre[y[p]]) f[p^1]-=minf,f[p]+=minf;
					flow+=minf;u=S;
				}
			} else {
				if (!(--gap[dis[u]])) break;
				int mind=Tn;
				c[u]=fst[u];
				for (int j=fst[u];j;j=nxt[j]) if (fabs(f[j])>EPS&&dis[y[j]]<mind)
					mind=dis[y[j]],c[u]=j;
				dis[u]=mind+1;
				gap[dis[u]]++;
				if (u!=S) u=y[pre[u]];
			}
		}
		q[0]=S; t=1;
		rep(i,0,Tn) dis[i]=Tn;
		dis[S]=0;
		rep(i,0,t) {
			int u=q[i];
			for (int j=fst[u];j;j=nxt[j]) if (dis[y[j]]>dis[u]+1&&fabs(f[j])>EPS) {
				dis[y[j]]=dis[u]+1;
				q[t++]=y[j];
			}
		}
		ts=0;
		rep(i,0,Tn) for (int j=fst[i];j;j=nxt[j]) if (dis[i]<Tn&&dis[y[j]]>=Tn) ts+=slope[j];
		return flow;
	}
};

db bel[N];
int sl[N];
int check(double t) {
	rep(i,1,n+1) bel[i]=0,sl[i]=0;
	flow::init(0,n+1,n+2);
	rep(i,0,m) {
		db l=a[i]*t+b[i],r=c[i]*t+d[i];
		flow::add(u[i],v[i],c[i]-a[i],r-l);
		bel[u[i]]+=l; bel[v[i]]-=l;
		sl[u[i]]+=a[i]; sl[v[i]]-=a[i];
	}
	db sf=0;
	int ss=0;
	rep(i,1,n+1) if (bel[i]>0) {
		sf+=bel[i]; flow::add(i,n+1,sl[i],bel[i]);
		ss+=sl[i];
	} else flow::add(0,i,-sl[i],-bel[i]);
	db r=flow::sap();
	if (ts==ss) {
		if (cmp(r,sf)==-1) return 2;
		else return 1;
	} else if (ts>ss) return 0;
	else return 2;
}
double gao(int ty) {
	double l=0,r=1;
	rep(it,0,30) {
		double md=(l+r)*0.5;
		if (check(md)>=ty) r=md; else l=md;
	}
	return 0.5*(l+r);
}
int main() {
	scanf("%d%d",&n,&m);
	rep(i,0,m) scanf("%d%d%d%d%d%d",u+i,v+i,a+i,b+i,c+i,d+i);
	db l=gao(1),r=gao(2);
	printf("%.10f\n",r-l);
}

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
typedef long long ll;
int fst[SZ],nxt[SZ],vb[SZ],ff[SZ],M=1,N=0;
#define ad_de ad_dl
ll cap[SZ];
void _ad_dl(int a,int b,ll c)
{++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;cap[M]=c;}
void ad_dl(int a,int b,ll c)
{_ad_dl(a,b,c); _ad_dl(b,a,0);}
#define d d_
int S,T,q[SZ],d[SZ];
bool bfs()
{
	memset(d,-1,4*(N+1));
	d[T]=0; q[1]=T; int h=1,t=2;
	while(h!=t)
	{
		int cur=q[h++];
		for(int e=fst[cur];e;e=nxt[e])
		{
			int b=vb[e];
			if(d[b]==-1&&cap[e^1])
			{
				d[b]=d[cur]+1, q[t++]=b;
				if(b==S) return 1;
			}
		}
	}
	return d[S]!=-1;
}
ll dfs(int x,ll f)
{
	if(f<=0) return 0;
	if(x==T) return f;
	ll ca=0;
	for(int& e=fst[x];e;e=nxt[e])
	{
		int b=vb[e];
		if(d[b]+1!=d[x]) continue;
		ll w=dfs(b,(cap[e]<f-ca)?cap[e]:(f-ca));
		cap[e]-=w; cap[e^1]+=w; ca+=w;
		if(ca==f) break;
	}
	if(!ca) d[x]=-1;
	return ca;
}
ll dinic()
{
	ll ans=0;
	memcpy(ff,fst,4*(N+1));
	while(bfs())
		ans+=dfs(S,2e18), memcpy(fst,ff,4*(N+1));
	return ans;
}
#undef d
const ll G=1.01e7;
int n,e,u[SZ],v[SZ],a[SZ],b[SZ],c[SZ],d[SZ];
ll ds[SZ];
ll f(ll x)
{
	for(int i=1;i<=N;++i) fst[i]=ds[i]=0;
	N=n; S=++N; T=++N; M=1;
	for(int i=1;i<=e;++i)
	{
		ll L=a[i]*x+b[i]*G,R=c[i]*x+d[i]*G;
		ad_de(u[i],v[i],R-L); ds[v[i]]+=L; ds[u[i]]-=L;
	}
	ll sb=0;
	for(int i=1;i<=N;++i)
		if(ds[i]>0) ad_de(S,i,ds[i]),sb+=ds[i];
		else if(ds[i]<0) ad_de(i,T,-ds[i]);
	ll aa=sb-dinic();
	return aa;
}
int main()
{
	cin>>n>>e;
	for(int i=1;i<=e;++i)
		cin>>u[i]>>v[i]>>a[i]>>b[i]>>c[i]>>d[i];
	ll l=0,r=G;
	while(r-l>10)
	{
		ll m1=l+(r-l)/3,m2=r-(r-l)/3;
		if(f(m1)<f(m2)) r=m2; else l=m1;
	}
	pair<ll,ll> mi(8e18,8e18);
	for(ll t=l;t<=r;++t)
		mi=min(mi,mp(f(t),t));
	if(mi.fi)
	{
		puts("0");
		return 0;
	}
	l=mi.se,r=G;
	while(l<r)
	{
		ll m=(l+r+1)>>1;
		if(f(m)) r=m-1; else l=m;
	}
	ll ans=l;
	l=0,r=mi.se;
	while(l<r)
	{
		ll m=(l+r)>>1;
		if(f(m)) l=m+1; else r=m;
	}
	ans-=l;
	printf("%.10lf\n",ans/ld(G));
}

#include <bits/stdc++.h>
using namespace std;

namespace Dinic {
	typedef long long F;
	const F INF = 1LL<<60;

	const int N = 1100;
	const int M = 11000;

	int fst[N], nxt[M], to[M];
	F cap[M];
	int dis[N], q[N], ptr[N];
	int V, E;

	void init() {
		memset(fst, -1, sizeof fst);
		V = E = 0;
	}
	inline int add_node() { V++; return V-1; }
	inline void add_edge(int u, int v, F c) {
		to[E] = v, cap[E] = c, nxt[E] = fst[u], fst[u] = E++;
		to[E] = u, cap[E] = 0, nxt[E] = fst[v], fst[v] = E++;
	}
	inline bool bfs(int S, int T, int n) {
		memset(dis, -1, sizeof(int) * n);
		int h = 0, t = 0;
		dis[S] = 0, q[t++] = S;
		while (h < t) {
			int u = q[h++];
			for (int e = fst[u]; ~e; e = nxt[e]) if (cap[e] > 0 && dis[to[e]] == -1) {
				dis[to[e]] = dis[u] + 1, q[t++] = to[e];
				if (to[e] == T) return 1;
			}
		}
		return (dis[T] != -1);
	}
	F dfs(int u, int T, F f) {
		if (u == T) return f;
		for (int &e = ptr[u]; ~e; e = nxt[e]) if (cap[e] > 0 && dis[to[e]] > dis[u]) {
			F ret = dfs(to[e], T, min(f, cap[e]));
			if (ret > 0) {
				cap[e] -= ret, cap[e ^ 1] += ret;
				return ret;
			}
		}
		return 0;
	}
	F max_flow(int S, int T, int n = V) {
		F ret = 0;
		while (bfs(S, T, n)) {
			memcpy(ptr, fst, sizeof(int) * n);
			for (F cur; (cur = dfs(S, T, INF)) > 0; ret += cur);
		}
		return ret;
	}
}

long long ssum[1100], tsum[1100];

int n, m;
const int D = 10000000;

struct Edge {
	int u, v, a, b, c, d;
	void input() { scanf("%d%d%d%d%d%d", &u, &v, &a, &b, &c, &d); }
} e[2200];

long long calc(int mid) {
	Dinic::init();
	for (int i = 1; i <= n; i++) ssum[i] = tsum[i] = 0;
	for (int i = 1; i <= m; i++) {
		int u = e[i].u, v = e[i].v;
		long long l = e[i].a * 1LL * mid + e[i].b * 1LL * D;
		long long r = e[i].c * 1LL * mid + e[i].d * 1LL * D;
		ssum[v] += l, tsum[u] += l;
		Dinic::add_edge(u, v, r - l);
	}
	for (int i = 1; i <= n; i++) {
		if (ssum[i]) Dinic::add_edge(0, i, ssum[i]);
		if (tsum[i]) Dinic::add_edge(i, n+1, tsum[i]);
	}
	long long tot = 0;
	for (int i = 1; i <= n; i++) tot += ssum[i];
	return tot - Dinic::max_flow(0, n+1, n+2);
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++) e[i].input();
	int st = 0, en = D;
	while (st < en - 1) {
		int mid1 = (st * 2 + en) / 3;
		int mid2 = (st + en * 2) / 3;
		long long ret1 = calc(mid1);
		if (ret1 == 0) {
			st = en = mid1;
			break;
		}
		long long ret2 = calc(mid2);
		if (ret2 == 0) {
			st = en = mid2;
			break;
		}
		if (ret1 > ret2) {
			st = mid1 + 1;
		} else {
			en = mid2;
		}
	}
	int ans = 0;
	{
		int lo = 0, hi = st;
		while (lo < hi) {
			int mid = lo + hi >> 1;
			if (calc(mid) == 0) hi = mid;
			else lo = mid + 1;
		}
		ans -= lo;
	}
	{
		int lo = st, hi = D;
		while (lo < hi) {
			int mid = lo + hi + 1 >> 1;
			if (calc(mid) == 0) lo = mid;
			else hi = mid - 1;
		}
		ans += lo;
	}
	printf("%.10lf\n", ans * 1.0 / D);
	return 0;
}

#include <bits/stdc++.h>
#define mk make_pair
#define ll long long
using namespace std;
const int N = 2e5;
const ll inf = 1e18;
vector<int> Eid[N];
int n, m, cnt, S, T, in[N], out[N], cur[N];
ll d[N];
struct Edge {
	ll c;
	int v;
} E[N];
void AddEdge(int x, int y, ll c) {
	E[cnt].v = y, E[cnt].c = c;
	Eid[x].push_back(cnt++);
	E[cnt].v = x, E[cnt].c = 0;
	Eid[y].push_back(cnt++);
}
bool BFS() {
	static int Q[N];
	int x, ql, qr;
	for (int i = 0; i <= T; i++) d[i] = -1;
	Q[ql = qr = 0] = S; d[S] = 0;
	while (ql <= qr) {
		x = Q[ql++];
		for (int i = 0; i < Eid[x].size(); i++) {
			const Edge &e = E[Eid[x][i]];
			if (e.c && d[e.v] == -1) {
				Q[++qr] = e.v;
				d[e.v] = d[x] + 1;
				if (e.v == T) return 1;
			}
		}
	}
	return 0;
}
ll Aug(int x, ll a) {
	if (x == T) return a;
	ll aug = 0, delta;
	for (int &i = cur[x]; i < Eid[x].size(); i++) {
		Edge &e = E[Eid[x][i]];
		if (e.c && d[e.v] == d[x] + 1) {
			delta = Aug(e.v, min(a, e.c));
			if (delta) {
				e.c -= delta;
				E[Eid[x][i] ^ 1].c += delta;
				aug += delta;
				if (!(a -= delta)) break;
			}
		}
	}
	if (!aug) d[x] = -1;
	return aug;
}
ll MaxFlow() {
	ll flow = 0;
	while(BFS()) {
		for (int i = 0; i <= T; i++) cur[i] = 0;
		flow += Aug(S, inf);
	}
	return flow;
}
int id[N];
int u[N], v[N];
ll A[N], B[N], C[N], D[N];
ll check(int t) {
	ll ans = 0;
	for (int i = 1; i <= m; ++i) {
		for (int j = id[i]; j < id[i] + 6; ++j) E[j].c = 0;
		ll l = A[i] * t + B[i];
		ll r = C[i] * t + D[i];
		E[id[i]].c = E[id[i] + 2].c = l;
		E[id[i] + 4].c = r - l;
		ans += l;
	}
	return ans - MaxFlow();
}
int main() {
	cin >> n >> m;
	T = n + 1;
	for (int i = 1; i <= m; ++i) {
		scanf("%d %d %I64d %I64d %I64d %I64d", u + i, v + i, A + i, B + i, C + i, D + i);
		B[i] *= 1e8;
		D[i] *= 1e8;
		id[i] = cnt;
		AddEdge(S, v[i], 0);
		AddEdge(u[i], T, 0);
		AddEdge(u[i], v[i], 0);
	}
	ll l1, r1, l = 0, r = 1e8, mid;
	while (r - l > 6) {
		l1 = (r - l) / 3 + l;
		r1 = r - (r - l) / 3;
		if (check(l1) <= check(r1))
			r = r1;
		else
			l = l1;
	}
	ll tmp = check(l1), tmp1;
	for (int i = l1; i <= r1; ++i) {
		tmp1 = check(i);
		if (tmp1 < tmp) {
			l1 = i;
			tmp = tmp1;
		}
	}
	if (tmp) return puts("0");
	l = l1; r = 1e8;
	while (l < r) {
		if (l + 1 == r) {
			if (check(r) == 0)
				l++;
			else
				r--;
			break;
		}
		mid = l + r >> 1;
		if (check(mid) == 0)
			l = mid;
		else
			r = mid;
	}
	printf("%.10f\n", (l - l1 + 1) / 1e8);
}

#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <list>
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;

#define PB push_back
#define MP make_pair
#define SZ(v) ((int)(v).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n) FORE(i,0,n)
#define FORSZ(i,a,v) FOR(i,a,SZ(v))
#define REPSZ(i,v) REP(i,SZ(v))
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }

const int MAXN = 1000;
const int MAXM = 2000;
struct E { int from, to, al, bl, ar, br; double l, r; };

const int GMAXN = MAXN + 2;
const int GMAXM = 2 * MAXN + MAXM;
const double eps = 1e-12;
struct G {
	int n, m;
	int ghead[GMAXN], gnxt[2 * GMAXM], gto[2 * GMAXM]; double gcap[2 * GMAXM];

	int level[GMAXN];
	int q[GMAXN], qhead, qtail;
	int gcur[GMAXN];
	int path[GMAXN], npath;

	bool incut[2 * GMAXM];

	void init(int _n) { n = _n, m = 0; REP(i, n) ghead[i] = -1; }
	int addedge(int a, int b, double cap) {
		int ret = m;
		//printf("addedge(%d,%d,%lf)\n", a, b, cap);
		gnxt[m] = ghead[a], ghead[a] = m, gto[m] = b, gcap[m] = cap; ++m;
		gnxt[m] = ghead[b], ghead[b] = m, gto[m] = a, gcap[m] = 0; ++m;
		return ret;
	}
	bool calclevel(int s,int t) {
		REP(i, n) level[i] = -1; qhead = qtail = 0;
		level[s] = 0, q[qhead++] = s;
		while (qtail < qhead) {
			int at = q[qtail++];
			for (int x = ghead[at]; x != -1; x = gnxt[x]) if (gcap[x] >= eps) {
				int to = gto[x]; if (level[to] == -1) level[to] = level[at] + 1, q[qhead++] = to;
			}
		}
		//printf("level:"); REP(i, n) printf(" %d", level[i]); puts("");
		return level[t] != -1;
	}
	bool augment(int at, int t, double lim, double &flow) {
		if (at == t) { flow = lim; path[npath++] = at; return true; }
		for (; gcur[at] != -1; gcur[at] = gnxt[gcur[at]]) {
			int x = gcur[at], to = gto[x];
			if (gcap[x] < eps || level[to] != level[at] + 1) continue;
			if (augment(to, t, min(lim, gcap[x]), flow)) { gcap[x] -= flow; gcap[x ^ 1] += flow; path[npath++] = at; return true; }
		}
		return false;
	}
	double maxflow(int s, int t) {
		double ret = 0;
		while (calclevel(s, t)) {
			REP(i, n) gcur[i] = ghead[i];
			while (true) {
				double cur; npath = 0;
				if (!augment(s, t, 1e200, cur)) break;
				ret += cur;
				//reverse(path, path + npath); printf("found path"); REP(i, npath) printf(" %d", path[i]); printf(" of value %lf\n", cur);
			}
		}
		return ret;
	}
	void calccut(int s,int t) {
		assert(!calclevel(s, t));
		REP(i, m) incut[i] = false;
		REP(at, n) if (level[at] >= 0) for (int x = ghead[at]; x != -1; x = gnxt[x]) if (level[gto[x]] == -1) incut[x] = true;
		//printf("cut:"); REP(x, m) if (incut[x]) printf(" %d->%d", gto[x ^ 1], gto[x]); puts("");
	}
};

int n, m;
E e[MAXM];

G g;
double insum[MAXN], outsum[MAXN];
int inid[MAXN], outid[MAXN], eid[MAXM];

void findcut(double t, int &acut, int &bcut) {
	REP(i, m) e[i].l = e[i].al*t + e[i].bl, e[i].r = e[i].ar*t + e[i].br;
	REP(i, n) insum[i] = outsum[i] = 0; REP(i, m) outsum[e[i].from] += e[i].l, insum[e[i].to] += e[i].l;

	g.init(n + 2); int src = n, dst = n + 1;
	REP(i, n) inid[i] = insum[i] != 0 ? g.addedge(src, i, insum[i]) : -1;
	REP(i, n) outid[i] = outsum[i] != 0 ? g.addedge(i, dst, outsum[i]) : -1;
	REP(i, m) eid[i] = e[i].l < e[i].r ? g.addedge(e[i].from, e[i].to, e[i].r - e[i].l) : -1;
	g.maxflow(src, dst);
	g.calccut(src, dst);

	acut = bcut = 0;
	REP(i, m) acut -= e[i].al, bcut -= e[i].bl;
	REP(i, m) {
		if (eid[i] != -1 && g.incut[eid[i]]) acut += e[i].ar - e[i].al, bcut += e[i].br - e[i].bl;
		if (outid[e[i].from] != -1 && g.incut[outid[e[i].from]]) acut += e[i].al, bcut += e[i].bl;
		if (inid[e[i].to] != -1 && g.incut[inid[e[i].to]]) acut += e[i].al, bcut += e[i].bl;
	}
}

bool findnonneg(double &tres) {
	double l = 0, r = 1;
	REP(rep, 100) {
		if (l > r) return false;
		double m = l + (r - l) / 2;
		int a, b; findcut(m, a, b);
		//printf("%lf: %lf (%d*t+%d)\n", m, a*m + b, a, b);
		if (a > 0) {
			if (a*m + b >= 0) { tres = m; return true; }
			double nl = -1.0 * b / a; assert(nl > l); l = nl;
		} else if (a < 0) {
			if (a*m + b >= 0) { tres = m; return true; }
			double nr = -1.0 * b / a; assert(nr < r); r = nr;
		} else {
			if (b >= 0) { tres = m; return true; }
			return false;
		}
	}
	printf("err: %.15lf..%15lf\n", l, r);
	return false;
}

double findtmn(double tok) {
	double l = 0, r = tok;
	REP(rep, 100) {
		if (r - l < 1e-7) break;
		double m = l + (r - l) / 2;
		int a, b; findcut(m, a, b);
		//printf("%lf: %lf (%d*t+%d)\n", m, a*m + b, a, b);
		if (a*m + b >= 0) {
			r = m;
		} else {
			assert(a > 0);
			double nl = -1.0 * b / a; assert(nl > l); l = nl;
		}
	}
	return r;
}

double findtmx(double tok) {
	double l = tok, r = 1;
	REP(rep, 100) {
		if (r - l < 1e-7) break;
		double m = l + (r - l) / 2;
		int a, b; findcut(m, a, b);
		//printf("%lf: %lf (%d*t+%d)\n", m, a*m + b, a, b);
		if (a*m + b >= 0) {
			l = m;
		} else {
			assert(a < 0);
			double nr = -1.0 * b / a; assert(nr < r); r = nr;
		}
	}
	return l;
}

void run() {
	scanf("%d%d", &n, &m);
	REP(i, m) scanf("%d%d%d%d%d%d", &e[i].from, &e[i].to, &e[i].al, &e[i].bl, &e[i].ar, &e[i].br), --e[i].from, --e[i].to;

	/*REPE(rep, 100) {
		double t = 0.01*rep;
		//if (rep != 25) continue;
		int a, b; findcut(t, a, b);
		printf("%lf: %lf (%d*t+%d)\n", t, a*t + b, a, b);
	}*/

	double tnonneg;
	if (!findnonneg(tnonneg)) { printf("0\n"); return; }
	//printf("tnonneg=%.15lf\n", tnonneg);

	double tmn = findtmn(tnonneg);
	//printf("tmn=%.15lf\n", tmn);
	double tmx = findtmx(tnonneg);
	//printf("tmx=%.15lf\n", tmx);

	printf("%.15lf\n", tmx - tmn);
}

int main() {
	run();
	return 0;
}

#include<bits/stdc++.h>
#define MN 2000
#define S 0
#define T 1001
#define eps 1e-11
#define ld long double
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
ld d[T+5],in[T+5];
int n,m,q[T+5],head[T+5],cnt,top,c[T+5];
struct Edge{int u,v,a,b,c,d;}s[MN+5];
struct edge{int to,next;ld w;}e[100005];
inline void ins(int f,int t,ld w)
{
	e[++cnt]=(edge){t,head[f],w};head[f]=cnt;
	e[++cnt]=(edge){f,head[t],0};head[t]=cnt;
}
bool bfs()
{
	for(int i=1;i<=T;++i) d[i]=1e9;int i,j;
	for(d[q[top=i=1]=S]=0;i<=top;++i)
		for(j=c[q[i]]=head[q[i]];j;j=e[j].next)
			if(e[j].w>eps&&d[q[i]]+1<d[e[j].to])
				d[q[++top]=e[j].to]=d[q[i]]+1;
	return d[T]<1e8;
}
ld dfs(int x,ld f)
{
	if(x==T) return f;ld used=0;
	for(int&i=c[x];i;i=e[i].next)
		if(e[i].w>eps&&d[e[i].to]==d[x]+1)
		{
			ld w=dfs(e[i].to,min(f-used,e[i].w));
			used+=w;e[i].w-=w;e[i^1].w+=w;
			if(f-used<eps) return f;
		}
	return used;
}
ld Solve(ld t)
{
	cnt=1;memset(head,0,sizeof(head));
	memset(in,0,sizeof(in));
	for(int i=1;i<=m;++i)
	{
		ld l=t*s[i].a+s[i].b,r=t*s[i].c+s[i].d;
		ins(s[i].u,s[i].v,r-l);
		in[s[i].v]+=l;in[s[i].u]-=l;
	}
	ld res=0;
	for(int i=1;i<=n;++i)
		if(in[i]>0) res+=in[i],ins(S,i,in[i]);
		else ins(i,T,-in[i]);
	while(bfs()) res-=dfs(S,1e9);
	return res;
}
int main()
{
	n=read();m=read();
	for(int i=1;i<=m;++i)
		s[i].u=read(),s[i].v=read(),
		s[i].a=read(),s[i].b=read(),
		s[i].c=read(),s[i].d=read();
	ld l=0,r=1,ok=-1;
	for(int i=1;i<=50;++i)
	{
		ld m1=l+(r-l)/3,m2=m1+(r-l)/3;
		ld r1=Solve(m1),r2=Solve(m2);
		if(r1<eps) {ok=m1;break;}
		if(r2<eps) {ok=m2;break;}
		if(r1<r2) r=m2; else l=m1;
	}
	if(ok<0) return 0*puts("0");
	l=0,r=ok;ld L=ok,R=ok;
	for(int i=1;i<=50;++i)
	{
		ld mid=(l+r)*0.5;
		if(Solve(mid)<eps) L=mid,r=mid;
		else l=mid;
	}
	l=ok;r=1;
	for(int i=1;i<=50;++i)
	{
		ld mid=(l+r)*0.5;
		if(Solve(mid)<eps) R=mid,l=mid;
		else r=mid;
	}
	printf("%.10lf\n",(double)(R-L));
	return 0;
}

#include<bits/stdc++.h>
#define maxn 10010
using namespace std;
typedef long long ll;
const ll M=(ll)1e9;
struct edge{
	int r,nxt;
	ll w;
}e[maxn<<1];
ll deg[maxn],a[maxn],b[maxn],c[maxn],d[maxn];
int fr[maxn],to[maxn],n,m;
int q[maxn],l,r,cur[maxn],dep[maxn],head[maxn],esz,S,T;
void addedge(int u,int v,ll w){
	e[++esz].r=v;e[esz].nxt=head[u];head[u]=esz;e[esz].w=w;
	e[++esz].r=u;e[esz].nxt=head[v];head[v]=esz;e[esz].w=0;
}
bool bfs(){
	for(int i=S;i<=T;++i)cur[i]=head[i],dep[i]=0;
	l=r=0,q[r++]=S,dep[S]=1;
	while(l<r){
		int u=q[l++];
		for(int t=head[u];t;t=e[t].nxt)if(e[t].w&&!dep[e[t].r])
			dep[e[t].r]=dep[u]+1,q[r++]=e[t].r;
	}
	return dep[T]!=0;
}
ll find(int u,ll flow){
	if(u==T)return flow;
	ll used=0,a=0;
	for(int& t=cur[u];t;t=e[t].nxt)if(e[t].w&&dep[e[t].r]==dep[u]+1){
		a=find(e[t].r,min(flow-used,e[t].w));
		used+=a,e[t].w-=a,e[t^1].w+=a;
		if(flow==used)return used;
	}
	return used;
}
ll dinic(){
	ll ans=0,a;
	while(bfs())ans+=find(S,1ll<<60);//,printf("[%.9lf]\n",a);
	return ans;
}
ll sol(ll t){
	ll sum=0;
	esz=1,S=0,T=n+1;
	for(int i=S;i<=T;++i)head[i]=deg[i]=0;
	for(int i=1;i<=m;++i){
		ll l=a[i]*t+b[i],r=c[i]*t+d[i];
		deg[to[i]]+=l;
		deg[fr[i]]-=l;
//		addedge(S,to[i],l);
//		addedge(fr[i],T,l);
		addedge(fr[i],to[i],r-l);
//		sum+=l;
	}
	for(int i=1;i<=n;++i)
		if(deg[i]>0)sum+=deg[i],addedge(S,i,deg[i]);
		else addedge(i,T,-deg[i]);
	return sum-dinic();
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;++i){
	//	fr[i]=rand()%n+1,to[i]=rand()%n+1;
	//	while(fr[i]==to[i])fr[i]=rand()%n+1,to[i]=rand()%n+1;
	//	a[i]=rand()%20,b[i]=rand()%20,c[i]=rand()%20,d[i]=rand()%20+a[i]+c[i];
		scanf("%d%d%lld%lld%lld%lld",&fr[i],&to[i],&a[i],&b[i],&c[i],&d[i]);
		b[i]*=M,d[i]*=M;
	}
	ll l=0,r=M;
	for(int i=0;r-l>3;++i){
		ll mid1=(l+l+r)/3,mid2=(l+r+r)/3;
		ll f1=sol(mid1),f2=sol(mid2);
		//printf("[%lld,%lld]",f1,f2);
		if(f1>f2)l=mid1;
		else r=mid2;
	}
	ll l1=0,r1=l;
	for(int i=0;l1<r1;++i){
		ll mid=(l1+r1)/2;
		if(sol(mid)==0)r1=mid;
		else l1=mid+1;
	}
	ll l2=l,r2=M;
	for(int i=0;l2<r2;++i){
		ll mid=(l2+r2)/2;
		if(sol(mid)==0)l2=mid+1;
		else r2=mid;
	}
//	printf("[%.10lf,%.10lf]",sol(0),sol(1));
	printf("%.10lf",(double)(l2-l1)/(double)M);
}

#include<cstdio>
#include<algorithm>
#include<vector>
#define double long double
#define N_ 2010
#define M_ 10100
#define INF 1e9
using namespace std;
class MaxFlow {
public:
	struct Edge {
		int b, e;
		double f;
	}E[M_ * 2];
	vector<int>G[N_];
	int Level[N_], Q[N_], PV[N_], source, sink, EC, n;
	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, 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;
	}
	double BlockFlow(int a, double f) {
		if (a == sink)return f;
		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) {
				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() {
		double t;
		while (GetLevel()) {
			for (int i = 1; i <= n; i++)PV[i] = G[i].size() - 1;
			while ((t = BlockFlow(source, INF)) > 0) flow += t;
		}
	}
}G1;
struct EdEd {
	int b, e, A, B, C, D;
}w[2010];
int n, m;
double Calc(double tt) {
	G1.init(n + 2, n + 1, n + 2);
	int i;
	double sum = 0.0;
	for (i = 0; i < m; i++) {
		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;
}
double res;
void Make(double b, double e) {
	double mid;
	for (int i = 0; i < 50; i++) {
		mid = (b + e)*0.5;
		if (Calc(mid) < 1e-9) {
			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);
	}
	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;
		double t1 = Calc(m1);
		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);
}

#include <bits/stdc++.h>
using namespace std;

#define s 0
#define t (n+1)

typedef long long ll;

const int N = 50010;
const ll E = 1e7;
const ll INF = 1e18;

ll n, m, ct;
ll u[N], v[N], a[N], b[N], c[N], d[N];
ll hd[N], nxt[N], to[N], cp[N];
ll dst[N], que[N], cur[N];
ll head, tail;

void link(int u, int v, ll c) {
	to[++ct] = v; cp[ct] = c;
	nxt[ct] = hd[u]; hd[u] = ct;
}

bool bfs() {
	for (int i = s; i <= t; i++) dst[i] = 0;
	dst[s] = 1;
	head = 0, tail = 1;
	que[++head] = s;
	while (head <= tail) {
		int u = que[head++];
		for (int i = hd[u]; i; i = nxt[i]) {
			int v = to[i];
			if (!dst[v] && cp[i] > 0) {
				dst[v] = dst[u] + 1;
				que[++tail] = v;
				if (v == t) break;
			}
		}
	}
	return dst[t];
}

ll dfs(ll u, ll f) {
	if (u == t || f == 0) return f;
	ll vf = 0;
	for (ll &i = cur[u]; i; i = nxt[i]) {
		if (cp[i] > 0 && dst[to[i]] == dst[u]+1) {
			ll fl = dfs(to[i], min(f, cp[i]));
			if (fl) {
				cp[i] -= fl;
				cp[i^1] += fl;
				f -= fl;
				vf += fl;
				if (!f) break;
			}
		}
	}
	return vf;
}

ll dinic() {
	ll ret = 0;
	while (bfs()) {
		for (int i = s; i <= t; i++) cur[i] = hd[i];
		while (ll f = dfs(s, INF)) ret += f;
	}
	return ret;
}

ll flow(ll x) {
	ll ret = 0; ct = 1;
	for (int i = s; i <= t; i++) hd[i] = 0;
	for (int i = 1; i <= m; i++) {
		ll lb = a[i]*x+b[i], ub = c[i]*x+d[i];
		ret += lb;
		link(s, v[i], lb); link(v[i], s, 0);
		link(u[i], t, lb); link(t, u[i], 0);
		link(u[i], v[i], ub-lb); link(v[i], u[i], 0);
	}
	return ret - dinic();
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		cin >> u[i] >> v[i] >> a[i] >> b[i] >> c[i] >> d[i];
		b[i] *= E; d[i] *= E;
	}
	int l = 0, r = E;
	while (r - l >= 3) {
		int df = (r-l)/3;
		if (flow(l+df) < flow(r-df)) r -= df;
		else l += df;
	}
	ll mf = flow(l);
	for (int i = l+1; i <= r; i++) {
		if (ll f = flow(i) < mf) { mf = f; l = i; }
	}
	if (mf > 0) return puts("0"), 0;
	int lp = 0, rp = l-1;
	while (lp <= rp) {
		int m = (lp+rp)/2;
		if (flow(m) > 0) lp = m+1;
		else rp = m-1;
	}
	ll ans = -lp;
	lp = l+1, rp = E;
	while (lp <= rp) {
		int m = (lp+rp)/2;
		if (flow(m) > 0) rp = m-1;
		else lp = m+1;
	}
	ans += rp;
	cout << fixed << setprecision(10) << (double)ans/E << endl;
	return 0;
}

#include <cstdio>
#include <algorithm>

#define ll long long
#define db double
#define ull unsigned long long
#define uint unsigned int
#define FIO ""
#define dbug(...) fprintf(stderr, __VA_ARGS__)

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;}

typedef std::pair<int, int> par;
#define fx first
#define fy second
#define mpar std::make_pair
#define pb push_back

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(FIO".in", "r", stdin); freopen(FIO".out", "w", stdout);}

const int maxn = 10080;
const ll M = 1e9;

int n, m, U[maxn], V[maxn];
ll a[maxn], b[maxn], c[maxn], d[maxn];

#include <queue>
#include <cstring>
namespace fa {
  const ll inf = 1ll << 60;
  int e_num = 1, S, T;
  int hed[maxn], dep[maxn];
  ll deg[maxn];

  struct Edge {
    int from, to, nxt;
    ll c;
  } edge[maxn * 4];

  void addedge(int from, int to, ll c) {
    edge[++e_num] = (Edge){from, to, hed[from], c};
    hed[from] = e_num;
  }

  void adde(int from, int to, ll 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];
  }

  ll dfs(int x, ll flow) {
    if (x == T) return flow;
    ll 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) {
        ll 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;
  }

  ll dinic() {
    ll ret = 0;
    while (bfs()) {
      ret += dfs(S, inf);
    }
    return ret;
  }

  ll check(ll t) {
    ll suml = 0;
    clear();
    S = 0, T = n + 1;
    memset(deg, 0, sizeof deg);
    for (int i = 1; i <= m; i++) {
      ll l = a[i] * t + b[i];
      ll 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]);
      }
    }
    ll d = dinic();
    return suml - d;
  }
}

ll 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) {
    ll mid = (L + R) >> 1;
    ll 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) {
    ll mid = (L + R + 1) >> 1;
    ll 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;
}

#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
using namespace std;
typedef long long LL;
const int MAXN = 1005;
const int MAXM = 3005;
const double inf = 1e8;
const double eps = 1e-8;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

int n, m, U[MAXM], V[MAXM], A[MAXM], B[MAXM], C[MAXM], D[MAXM];

struct Edge {
	int v, nxt;
	double w;
} e[MAXM << 1];
int first[MAXN], used[MAXN], eCnt;

inline void AddEdge(int u, int v, double w) {
	e[++eCnt].v = v;
	e[eCnt].w = w;
	e[eCnt].nxt = first[u];
	first[u] = eCnt;
}

inline void Add(int u, int v, double w) {
	AddEdge(u, v, w);
	AddEdge(v, u, 0);
}

double in[MAXN];
int S, T, level[MAXN], q[MAXN], head, tail;

bool BFS() {
	for (int i = 1; i <= T; ++i) {
		level[i] = -1;
		used[i] = first[i];
	}
	level[S] = 0;
	q[head = tail = 1] = S;
	while (head <= tail) {
		int u = q[head++];
		if (u == T) return 1;
		for (int i = first[u]; i; i = e[i].nxt) {
			int v = e[i].v;
			if (e[i].w > eps && level[v] == -1) {
				level[v] = level[u] + 1;
				q[++tail] = v;
			}
		}
	}
	return 0;
}

double DFS(int u, double flow) {
	if (u == T) return flow;
	double ret = 0;
	for (int i = used[u]; i; i = e[i].nxt, used[u] = i) {
		int v = e[i].v;
		if (e[i].w > eps && level[v] == level[u] + 1) {
			double tmp = DFS(v, min(flow, e[i].w));
			e[i].w -= tmp;
			e[i ^ 1].w += tmp;
			flow -= tmp;
			ret += tmp;
			if (flow < eps) break;
		}
	}
	return ret;
}

double Check(double mid) {
	eCnt= 1;
	for (int i = 1; i <= T; ++i) {
		in[i] = first[i] = 0;
	}
	for (int i = 1; i <= m; ++i) {
		double l = mid * A[i] + B[i];
		double r = mid * C[i] + D[i];
		Add(U[i], V[i], r - l);
		in[V[i]] += l;
		in[U[i]] -= l;
	}
	double ret = 0;
	for (int i = 1; i <= n; ++i) {
		if (in[i] > eps) {
			ret += in[i];
			Add(S, i, in[i]);
		} else if (in[i] < -eps) {
			Add(i, T, -in[i]);
		}
	}
	while (BFS()) {
		ret -= DFS(S, inf);
	}
	return ret;
}

void init() {
	read(n); read(m);
	for (int i = 1; i <= m; ++i) {
		read(U[i]); read(V[i]);
		read(A[i]); read(B[i]);
		read(C[i]); read(D[i]);
	}
	S = n + 1, T = S + 1;
}

void solve() {
	double L = 0, R = 1, ok = -1;
	while (R - L > eps) {
		double M1 = L + (R - L) / 3, M2 = R - (R - L) / 3;
		double D1 = Check(M1), D2 = Check(M2);
		if (D1 < eps) {
			ok = M1; break;
		}
		if (D2 < eps) {
			ok = M2; break;
		}
		(D1 > D2)? L = M1 : R = M2;
	}
	if (ok < 0) {
		printf("0\n");
		return;
	}
	double L1 = 0, R1 = ok;
	while (R1 - L1 > eps) {
		double M = (L1 + R1) / 2;
		(Check(M) > eps)? L1 = M : R1 = M;
	}
	double L2 = ok, R2 = 1;
	while (R2 - L2 > eps) {
		double M = (L2 + R2) / 2;
		(Check(M) > eps)? R2 = M : L2 = M;
	}
	printf("%.8lf\n", L2 - L1);
}

int main() {
	init();
	solve();
	return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define db long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int N=10005;
struct edge{
	int to,next;
	ll f;
}e[N];
int head[N],tot,S,T;
int dis[N],q[N];
void add(int x,int y,ll v){
	e[++tot]=(edge){y,head[x],v};
	head[x]=tot;
	e[++tot]=(edge){x,head[y],0};
	head[y]=tot;
}
bool bfs(){
	For(i,1,T) dis[i]=-1;
	int t=1; dis[q[1]=S]=0;
	For(h,1,t) for (int i=head[q[h]];i;i=e[i].next)
		if (dis[e[i].to]==-1&&e[i].f){
			dis[e[i].to]=dis[q[h]]+1;
			if (e[i].to==T) return 1;
			q[++t]=e[i].to;
		}
	return 0;
}
ll dfs(int x,ll flow){
	if (x==T) return flow;
	ll k,rest=flow;
	for (int i=head[x];i&&rest;i=e[i].next)
		if (dis[e[i].to]==dis[x]+1&&e[i].f){
			k=dfs(e[i].to,min(rest,e[i].f));
			e[i].f-=k; e[i^1].f+=k; rest-=k;
		}
	if (rest) dis[x]=-1;
	return flow-rest;
}
int x[N],y[N],n,m;
int a[N],b[N],c[N],d[N];
ll deg[N],LIM=100000000;
ll F(ll v){
	For(i,1,n+2) head[i]=deg[i]=0;
	S=n+1; T=n+2; tot=1;
	For(i,1,m){
		ll L=a[i]*v+b[i]*LIM;
		ll R=c[i]*v+d[i]*LIM;
		add(x[i],y[i],R-L);
		deg[y[i]]+=L;
		deg[x[i]]-=L;
	}
	ll ans=0;
	For(i,1,n)
		if (deg[i]>0) add(S,i,deg[i]),ans+=deg[i];
		else add(i,T,-deg[i]);
	for (;bfs();ans-=dfs(S,1ll<<60));
	return ans;
}
int main(){
	scanf("%d%d",&n,&m);
	For(i,1,m) scanf("%d%d%d%d%d%d",&x[i],&y[i],&a[i],&b[i],&c[i],&d[i]);
	int l=0,r=LIM;
	for (;r-l>=5;){
		int m1=l+(r-l)/3,m2=r-(r-l)/3;
		if (F(m1)<F(m2)) r=m2;
		else l=m1;
	}
	pll mn(8e18,8e18);
	For(i,l,r) mn=min(mn,pll(F(i),i));
	if (mn.fi) return puts("0"),0;
	l=mn.se+1; r=LIM;
	int ansr=mn.se;
	while (l<=r){
		int mid=(l+r)/2;
		if (!F(mid)) ansr=mid,l=mid+1;
		else r=mid-1;
	}
	l=0; r=mn.se-1;
	int ansl=mn.se;
	while (l<=r){
		int mid=(l+r)/2;
		if (!F(mid)) ansl=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%.10lf\n",1.0*(ansr-ansl)/LIM);
}

#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;
	}
}

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;
}

#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

const double dinf = 1e100;

template <typename T>
void pfill(T* pst, const T* ped, T val) {
	for ( ; pst != ped; *(pst++) = val);
}

template <typename T>
class Edge {
	public:
		int ed, nx;
		T r;

		Edge(int ed = 0, int nx = 0, T r = 0) : ed(ed), nx(nx), r(r) {	}
};

template <typename T>
class MapManager {
	public:
		int *h;
		vector<Edge<T> > es;

		MapManager() {	}
		MapManager(int n) {
			h = new int[(n + 1)];
			pfill(h, h + n + 1, -1);
		}
		~MapManager() {
			delete[] h;
			es.clear();
		}

		void addEdge(int u, int v, T r) {
			es.push_back(Edge<T>(v, h[u], r));
			h[u] = (signed) es.size() - 1;
		}

		void addArc(int u, int v, T cap) {
			addEdge(u, v, cap);
			addEdge(v, u, 0);
		}

		Edge<T>& operator [] (int p) {
			return es[p];
		}
};

class Dcmp {
	public:
		const static double eps;

		boolean operator () (double x) {
			return fabs(x) >= eps;
		}
} dcmp;

const double Dcmp :: eps = 5e-8;

template <typename Type>
class Network {
	public:
		int S, T;
		int *cur, *div;
		MapManager<Type> g;

		Network() {	}
		Network(int S, int T) : S(S), T(T), g(T + 1) {
			cur = new int[(T + 1)];
			div = new int[(T + 1)];
		}
		~Network() {
			delete[] cur;
			delete[] div;
		}

		boolean bfs() {
			static queue<int> que;
			pfill(div, div + T + 1, -1);
			div[S] = 0;
			que.push(S);
			while (!que.empty()) {
				int e = que.front();
				que.pop();
				for (int i = g.h[e], eu; ~i; i = g[i].nx) {
//					cerr << i << '\n';
					if (!dcmp(g[i].r))
						continue;
					eu = g[i].ed;
					if (!~div[eu]) {
						div[eu] = div[e] + 1;
						que.push(eu);
					}
				}
			}
			return ~div[T];
		}

		Type dfs(int p, Type minf) {
			if (p == T || !dcmp(minf))
				return minf;
			Type flow = 0, f;
			for (int& i = cur[p], e; (~i); i = cur[p], i = g[i].nx) {
				e = g[i].ed;
				if (div[e] == div[p] + 1 && dcmp(f = dfs(e, min(minf, g[i].r))) > 0) {
					flow += f;
					g[i].r -= f;
					g[i ^ 1].r += f;
					minf -= f;
					if (!dcmp(minf)) {
						break;
					}
				}
			}
			return flow;
		}

		Type dinic() {
			Type rt = 0;
//			cerr << g.h[0] << '\n';
			while (bfs()) {
				for (int i = 0; i <= T; i++)
					cur[i] = g.h[i];
				rt += dfs(S, dinf);
			}
			return rt;
		}
};

const int N = 1e3 + 5, M = 2e3 + 5;

int n, m;
Network<double> *network;
int us[M], vs[M], as[M], bs[M], cs[M], ds[M];

inline void init() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d%d%d%d%d%d", us + i, vs + i, as + i, bs + i, cs + i, ds + i);
	}
}

double in[N], out[N];
double build(double t) {
	MapManager<double> &g = network->g;
	for (int i = 1; i <= n; i++) {
		in[i] = out[i] = 0.0;
	}
	double rt = 0;
	for (int i = 0; i < m; i++) {
		double low = as[i] * t + bs[i], dif;
		g[i << 1].r = dif = (cs[i] - as[i]) * t + ds[i] - bs[i];
		g[i << 1 | 1].r = 0.0;
		out[us[i]] += low;
		in[vs[i]] += low;
		rt += low;
//		cerr << us[i] << " " << vs[i] << " " << dif << '\n';
	}
	int s = (m << 1);
	for (int i = 0; i < n; i++, s += 2) {
		g[s].r = in[i + 1];
		g[s | 1].r = 0;
//		cerr << 0 << " " << i + 1 << " " << in[i + 1] << '\n';
	}
	for (int i = 0; i < n; i++, s += 2) {
		g[s].r = out[i + 1];
		g[s | 1].r = 0;
//		cerr << i + 1 << " " << n + 1 << " " << out[i + 1] << '\n';
	}
	return rt;
}

inline void solve() {
	network = new Network<double>(0, n + 1);
	MapManager<double> &g = network->g;
	for (int i = 0; i < m; i++) {
		g.addArc(us[i], vs[i], 0.0);
	}
	for (int i = 0; i < n; i++) {
		g.addArc(0, i + 1, 0.0);
	}
	for (int i = 0; i < n; i++) {
		g.addArc(i + 1, n + 1, 0.0);
	}
	double div_eps = 1e-7;
	double l = 0, r = 1 - div_eps, mid, f1, f2, low;
	for (int _ = 0; l + Dcmp :: eps < r && _ < 64; _++) {
		mid = (l + r) / 2;
		low = build(mid);
		f1 = low - network->dinic();
		low = build(mid + div_eps);
		f2 = low - network->dinic();
		if (!dcmp(f1 - f2)) {
			r = mid;
		} else if (f1 > f2) {
			l = mid;
		} else {
			r = mid;
		}
	}
	double L = r;
	l = L, r = 1 - div_eps;
	for (int _ = 0; l + Dcmp :: eps < r && _ < 64; _++) {
		mid = (l + r) / 2;
		low = build(mid);
		f1 = low - network->dinic();
		low = build(mid + div_eps);
		f2 = low - network->dinic();
		if (!dcmp(f1 - f2)) {
			l = mid;
		} else if (f1 > f2) {
			l = mid;
		} else {
			r = mid;
		}
	}
	low = build(L);
	f1 = low - network->dinic();
	if (dcmp(f1)) {
		puts("0.000000");
	} else {
		printf("%.7lf\n", l - L);
	}
}

int main() {
	init();
	solve();
	return 0;
}

#include<bits/stdc++.h>
const int MN=2000;
const int S=0;
const int T=1001;
#define eps 1e-11
#define ld long double
using namespace std;
inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*f;
}
ld d[T+5],in[T+5];
int n,m,q[T+5],head[T+5],cnt,top,c[T+5];
struct Edge
{
	int u,v,a,b,c,d;
} s[MN+5];
struct edge
{
	int to,next;
	ld w;
} e[100005];
inline void ins(int f,int t,ld w)
{
	e[++cnt]=(edge){t,head[f],w};
	head[f]=cnt;
	e[++cnt]=(edge){f,head[t],0};
	head[t]=cnt;
}
bool bfs()
{
	for(int i=1; i<=T; ++i) d[i]=1e9;
	int i,j;
	for(d[q[top=i=1]=S]=0; i<=top; ++i)
		for(j=c[q[i]]=head[q[i]]; j; j=e[j].next)
			if(e[j].w>eps&&d[q[i]]+1<d[e[j].to])
				d[q[++top]=e[j].to]=d[q[i]]+1;
	return d[T]<1e8;
}
ld dfs(int x,ld f)
{
	if(x==T) return f;
	ld used=0;
	for(int&i=c[x]; i; i=e[i].next)
		if(e[i].w>eps&&d[e[i].to]==d[x]+1)
		{
			ld w=dfs(e[i].to,min(f-used,e[i].w));
			used+=w;
			e[i].w-=w;
			e[i^1].w+=w;
			if(f-used<eps) return f;
		}
	return used;
}
ld Solve(ld t)
{
	cnt=1;
	memset(head,0,sizeof(head));
	memset(in,0,sizeof(in));
	for(int i=1; i<=m; ++i)
	{
		ld l=t*s[i].a+s[i].b,r=t*s[i].c+s[i].d;
		ins(s[i].u,s[i].v,r-l);
		in[s[i].v]+=l;
		in[s[i].u]-=l;
	}
	ld res=0;
	for(int i=1; i<=n; ++i)
		if(in[i]>0) res+=in[i],ins(S,i,in[i]);
		else ins(i,T,-in[i]);
	while(bfs()) res-=dfs(S,1e9);
	return res;
}
int main()
{
	n=read();
	m=read();
	for(int i=1; i<=m; ++i)
		s[i].u=read(),s[i].v=read(),s[i].a=read(),s[i].b=read(),s[i].c=read(),s[i].d=read();
	ld l=0,r=1,ok=-1;
	for(int i=1; i<=50; ++i)
	{
		ld m1=l+(r-l)/3,m2=m1+(r-l)/3;
		ld r1=Solve(m1),r2=Solve(m2);
		if(r1<eps)
		{
			ok=m1;
			break;
		}
		if(r2<eps)
		{
			ok=m2;
			break;
		}
		if(r1<r2) r=m2;
		else l=m1;
	}
	if(ok<0) return 0*puts("0");
	l=0,r=ok;
	ld L=ok,R=ok;
	for(int i=1; i<=50; ++i)
	{
		ld mid=(l+r)*0.5;
		if(Solve(mid)<eps) L=mid,r=mid;
		else l=mid;
	}
	l=ok;
	r=1;
	for(int i=1; i<=50; ++i)
	{
		ld mid=(l+r)*0.5;
		if(Solve(mid)<eps) R=mid,l=mid;
		else r=mid;
	}
	printf("%.10lf\n",(double)(R-L));
	return 0;
}

#include <bits/stdc++.h>

#define itn int
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

#ifdef ONLINE_JUDGE
	inline int pidorand() {
		return ((rand() & 32767) << 15) | (rand() & 32767);
	}
	#define rand pidorand
#endif	// ONLINE_JUDGE

#ifdef OLBOEB
	#define return std::cerr << __FUNCTION__ << "\n"; return
#endif  // OLBOEB

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

struct Edge {
	int from, to;
	long long cap, flow;
};

const int INF = (int)2e9;

struct Dinic {
	int n;
	int s, t;
	vector<Edge> edges;
	vector<vector<int>> g;

	Dinic(int n, int s, int t) : n(n), s(s), t(t) {
		g.resize(n);
	}

	void add_edge(int from, int to, long long cap) {
		Edge e = {from, to, cap, 0};
		g[from].push_back(edges.size());
		edges.push_back(e);
		e = {to, from, 0, 0};
		g[to].push_back(edges.size());
		edges.push_back(e);
	}

	vector<int> d;

	bool bfs(int s, int t) {
		d.assign(n, INF);
		d[s] = 0;
		queue<int> q;
		q.push(s);
		while (!q.empty()) {
			int v = q.front();
			q.pop();
			for (auto id : g[v]) {
				auto e = edges[id];
				if (e.cap > e.flow && d[e.to] == INF) {
					d[e.to] = d[v] + 1;
					q.push(e.to);
				}
			}
		}
		return d[t] != INF;
	}

	vector<int> pointer;

	long long dfs(int v, int t, long long flow_add) {
		if (!flow_add) {
			return 0;
		}
		if (v == t) {
			return flow_add;
		}
		for (int& i = pointer[v]; i < (int)g[v].size(); ++i) {
			int id = g[v][i];
			int to = edges[id].to;
			if (d[to] != d[v] + 1) {
				continue;
			}
			long long pushed = dfs(to, t, min(flow_add, edges[id].cap - edges[id].flow));
			if (pushed) {
				edges[id].flow += pushed;
				edges[id ^ 1].flow -= pushed;
				return pushed;
			}
		}
		return 0;
	}

	long long get_flow() {
		long long flow = 0;
		while (bfs(s, t)) {
			pointer.assign(n, 0);
			while (long long pushed = dfs(s, t, INF)) {
				flow += pushed;
			}
		}
		return flow;
	}
};

using Network = Dinic;

/*
struct Network {
	struct Edge {
		int from, to;
		long long cap, flow;

		Edge(int fr, int to, long long cap, long long fl = 0):
			from(fr),to(to),cap(cap),flow(fl){}
	};

	int n;
	int s, t;
	vector<Edge> edges;
	vector<vector<int>> a;
	vector<int> ptr;

	Network(int n, int s, int t): n(n), s(s), t(t) {
		a.resize(n);
		ptr.resize(n);
	}

	void add_edge(int from, int to, long long cap) {
		int num = edges.size();
		edges.push_back(Edge(from, to, cap));
		edges.push_back(Edge(to, from, 0));
		a[from].push_back(num);
		a[to].push_back(num + 1);
	}

	long long push(int v, long long limit) {
		if (v == t)
			return limit;
		if (limit == 0)
			return 0;
		long long res = 0;
		while (ptr[v] < (int)a[v].size() && limit > 0){
			int pos = a[v][ptr[v]];
			int to = edges[pos].to;
			long long lm = min(limit, edges[pos].cap - edges[pos].flow);
			ptr[v]++;
			long long flow = push(to, lm);
			limit -= flow;
			res += flow;
			edges[pos].flow += flow;
			edges[pos ^ 1].flow -= flow;
		}
		return res;
	}

	long long get_flow() {
		long long res = 0;
		while (true){
			for (int i = 0; i < n; i++)
				ptr[i] = 0;
			long long flow = push(s, LLONG_MAX / 10);
			if (flow == 0)
				break;
			res += flow;
		}
		return res;
	}

	void show_flow() const {
		vector<vector<int>> out(n);
		for (int i = 0; i < (int)edges.size(); i += 2){
			if (edges[i].flow == 0)
				continue;
			int j = i;
			if (edges[i].flow < 0)
				j++;
			out[edges[j].from].push_back(j);
		}
		for (int i = 0; i < n; i++){
			for (int j : out[i]){
				cerr << i << " -> " << edges[j].to << " (" << edges[j].flow << "/" << edges[j].cap << ")\n";
			}
		}
	}
};
*/
int main() {
	int n = nxt();
	int m = nxt();
	vector<array<int, 6>> ed(m);
	for (int i = 0; i < m; ++i) {
		for (int j = 0; j < 6; ++j) {
			ed[i][j] = nxt();
		}
	}

	const long long many = 10000000;
	auto get = [&](long long t) {
		Network net(n + 2, 0, n + 1);
		for (auto e : ed) {
			net.add_edge(0, e[1], e[2] * t + e[3] * many);
			net.add_edge(e[0], n + 1, e[2] * t + e[3] * many);
			net.add_edge(e[0], e[1], e[4] * t + e[5] * many - (e[2] * t + e[3] * many));
		}

		// double res = 0;
		// for (int i = 0; i < m; ++i) {
		// 	res += net.edges[6 * i].flow - ed[i][2] * t - ed[i][3];
		// 	res += net.edges[6 * i + 2].flow - ed[i][2] * t - ed[i][3];
		// }

		long long res = net.get_flow();
		for (auto e : ed) {
			res -= e[2] * t + e[3] * many;
		}

		return res;
	};

	int l = 0, r = many;
	while (r > l + 2) {
		int m1 = (2 * l + r) / 3;
		int m2 = (l + 2 * r) / 3;

		if (get(m1) > get(m2)) {
			r = m2;
		} else {
			l = m1;
		}
	}
	int mid = l;
	for (int i = l + 1; i <= r; ++i) {
		if (get(i) > get(mid)) {
			mid = i;
		}
	}

	if (get(mid) < 0) {
		puts("0");
		return 0;
	}

	l = mid, r = many + 1;
	while (r > l + 1) {
		int m = (l + r) / 2;
		if (get(m) == 0) {
			l = m;
		} else {
			r = m;
		}
	}
	int ans = l;

	l = -1, r = mid;
	while (r > l + 1) {
		int m = (l + r) / 2;
		if (get(m) == 0) {
			r = m;
		} else {
			l = m;
		}
	}
	ans -= r;

	cout << setprecision(10) << fixed;
	cout << 1.0 * ans / many << "\n";

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair < int , int > pii;
typedef long double ldb;
#define mpr make_pair
#define FS first
#define SC second
#define PB push_back
template < typename T > void UMAX(T &a,T b){a=(a>b?a:b);}
template < typename T > void UMIN(T &a,T b){a=(a<b?a:b);}
LL readint(){
	char c=getchar();
	LL ret=0ll;
	bool neg=0;
	while(!(c>='0' && c<='9')){
		if(c=='-') neg=1;
		c=getchar();
	}
	while(c>='0' && c<='9'){
		ret=ret*10ll+(LL)(c-'0');
		c=getchar();
	}
	return neg?-ret:ret;
}
void putint(LL v){
	if(v<0){
		putchar('-');
		v=-v;
	}
	if(!v){
		putchar('0');
		return;
	}
	if(v>=10ll) putint(v/10ll);
	putchar('0'+(v%10ll));
}
const int S=1002,T=1003,inf=50000000;
namespace flows{
    struct edge{
        int v,r,id;
		ldb f;
        edge(int V,int R,ldb F,int _id){
            v=V;r=R;f=F;id=_id;
        }
    };
    vector < edge > adj[1005];
    int cur[1005],dis[1005];
    void init(){
        int i;
        for(i=0;i<1005;++i){
            adj[i].clear();
        }
    }
    void addedge(int u,int v,ldb f,int id,bool bi=0){
        adj[u].push_back(edge(v,(int)adj[v].size(),f,id));
        adj[v].push_back(edge(u,(int)adj[u].size()-1,bi?f:0,-1));
    }
    void bfs(){
        queue < int > Q;
        Q.push(S);
        dis[S]=0;
        while(!Q.empty()){
            int i,cv=Q.front();
            Q.pop();
            for(i=0;i<(int)adj[cv].size();++i){
                if(adj[cv][i].f>1e-8l && dis[adj[cv][i].v]==-1){
                    dis[adj[cv][i].v]=dis[cv]+1;
                    Q.push(adj[cv][i].v);
                }
            }
        }
    }
    ldb dfs(int ver,ldb cap){
        if(ver==T) return cap;
        for(int &i=cur[ver];i<(int)adj[ver].size();++i){
            edge &E=adj[ver][i];
            if(E.f>1e-8l && dis[E.v]>dis[ver]){
                ldb ret=dfs(E.v,min(cap,E.f));
                if(ret>1e-8l){
                    E.f-=ret;
                    adj[E.v][E.r].f+=ret;
                    return ret;
                }
            }
        }
        return 0;
    }
    ldb maxflow(){
        ldb ret=0,dlt;
        while(1){
            memset(dis,-1,sizeof(dis));
            memset(cur,0,sizeof(cur));
            bfs();
            if(dis[T]==-1) return ret;
            dlt=1;
            while(dlt>1e-8l){
                dlt=dfs(S,1e9l);
                ret+=dlt;
            }
        }
    }
}
int n,m;
vector < int > U,V,A,B,C,D;
ldb calc(ldb t){
	flows::init();
	int i,j,k;
//	for(i=0;i<n;++i){
//		flows::addedge(S,i,inf,-1);
//		flows::addedge(i,T,inf,-1);
//	}
	ldb suml=0;
	for(i=0;i<m;++i){
		int u=U[i],v=V[i],a=A[i],b=B[i],c=C[i],d=D[i];
		ldb l=a*t+b,r=c*t+d;
		suml+=l;
		flows::addedge(S,v,l,-1);
		flows::addedge(u,T,l,-1);
		flows::addedge(u,v,r-l,-1);
//		flows::addedge(u,v,c*t+d,-1);
//		flows::addedge(v,u,-(a*t+b),-1);
	}
	return flows::maxflow()-suml;
}
ldb getpeak(){
	ldb l=0,r=1;
	while(r-l>1e-7l){
		ldb dif=(r-l)/3;
		ldb mid1=l+dif,mid2=l+dif+dif;
		if(calc(mid1)<calc(mid2))
			l=mid1;
		else
			r=mid2;
	}
//	cout<<l<<endl;
	return l;
}
ldb getR(ldb peak){
	ldb l=peak,r=1,mid;
	while(r-l>1e-7l){
		mid=(l+r)/2;
		if(calc(mid)>-1e-8l)
			l=mid;
		else
			r=mid;
	}
//	cout<<'R'<<l<<endl;
	return l;
}
ldb getL(ldb peak){
	ldb l=0,r=peak,mid;
	while(r-l>1e-7l){
		mid=(l+r)/2;
		if(calc(mid)>-1e-8l)
			r=mid;
		else
			l=mid;
	}
//	cout<<'L'<<l<<endl;
	return l;
}
int main(){
	int i,j,k;
	n=readint();m=readint();
	for(i=0;i<m;++i){
		int u=readint()-1,v=readint()-1,a=readint(),b=readint(),c=readint(),d=readint();
		U.push_back(u);
		V.push_back(v);
		A.push_back(a);
		B.push_back(b);
		C.push_back(c);
		D.push_back(d);
	}
//	cout<<calc(0.33)<<' '<<calc(0.505)<<' '<<calc(0.66)<<' '<<calc(0.99)<<endl;
	ldb p=getpeak();
	printf("%.10f\n",(double)(getR(p)-getL(p)));
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair < int , int > pii;
typedef long double ldb;
#define mpr make_pair
#define FS first
#define SC second
#define PB push_back
template < typename T > void UMAX(T &a,T b){a=(a>b?a:b);}
template < typename T > void UMIN(T &a,T b){a=(a<b?a:b);}
LL readint(){
	char c=getchar();
	LL ret=0ll;
	bool neg=0;
	while(!(c>='0' && c<='9')){
		if(c=='-') neg=1;
		c=getchar();
	}
	while(c>='0' && c<='9'){
		ret=ret*10ll+(LL)(c-'0');
		c=getchar();
	}
	return neg?-ret:ret;
}
void putint(LL v){
	if(v<0){
		putchar('-');
		v=-v;
	}
	if(!v){
		putchar('0');
		return;
	}
	if(v>=10ll) putint(v/10ll);
	putchar('0'+(v%10ll));
}
const int S=1002,T=1003,inf=50000000;
namespace flows{
    struct edge{
        int v,r,id;
		ldb f;
        edge(int V,int R,ldb F,int _id){
            v=V;r=R;f=F;id=_id;
        }
    };
    vector < edge > adj[1005];
    int cur[1005],dis[1005];
    void init(){
        int i;
        for(i=0;i<1005;++i){
            adj[i].clear();
        }
    }
    void addedge(int u,int v,ldb f,int id,bool bi=0){
        adj[u].push_back(edge(v,(int)adj[v].size(),f,id));
        adj[v].push_back(edge(u,(int)adj[u].size()-1,bi?f:0,-1));
    }
    void bfs(){
        queue < int > Q;
        Q.push(S);
        dis[S]=0;
        while(!Q.empty()){
            int i,cv=Q.front();
            Q.pop();
            for(i=0;i<(int)adj[cv].size();++i){
                if(adj[cv][i].f>1e-8l && dis[adj[cv][i].v]==-1){
                    dis[adj[cv][i].v]=dis[cv]+1;
                    Q.push(adj[cv][i].v);
                }
            }
        }
    }
    ldb dfs(int ver,ldb cap){
        if(ver==T) return cap;
        for(int &i=cur[ver];i<(int)adj[ver].size();++i){
            edge &E=adj[ver][i];
            if(E.f>1e-8l && dis[E.v]>dis[ver]){
                ldb ret=dfs(E.v,min(cap,E.f));
                if(ret>1e-8l){
                    E.f-=ret;
                    adj[E.v][E.r].f+=ret;
                    return ret;
                }
            }
        }
        return 0;
    }
    ldb maxflow(){
        ldb ret=0,dlt;
        while(1){
            memset(dis,-1,sizeof(dis));
            memset(cur,0,sizeof(cur));
            bfs();
            if(dis[T]==-1) return ret;
            dlt=1;
            while(dlt>1e-8l){
                dlt=dfs(S,1e9l);
                ret+=dlt;
            }
        }
    }
}
int n,m;
vector < int > U,V,A,B,C,D;
ldb calc(ldb t){
	flows::init();
	int i,j,k;
//	for(i=0;i<n;++i){
//		flows::addedge(S,i,inf,-1);
//		flows::addedge(i,T,inf,-1);
//	}
	ldb suml=0;
	for(i=0;i<m;++i){
		int u=U[i],v=V[i],a=A[i],b=B[i],c=C[i],d=D[i];
		ldb l=a*t+b,r=c*t+d;
		suml+=l;
		flows::addedge(S,v,l,-1);
		flows::addedge(u,T,l,-1);
		flows::addedge(u,v,r-l,-1);
//		flows::addedge(u,v,c*t+d,-1);
//		flows::addedge(v,u,-(a*t+b),-1);
	}
	return flows::maxflow()-suml;
}
ldb getpeak(){
	ldb l=0,r=1;
	while(r-l>1e-7l){
		ldb dif=(r-l)/3;
		ldb mid1=l+dif,mid2=l+dif+dif;
		if(calc(mid1)<calc(mid2))
			l=mid1;
		else
			r=mid2;
	}
//	cout<<l<<endl;
	return l;
}
ldb getR(ldb peak){
	ldb l=peak,r=1,mid;
	while(r-l>1e-7l){
		mid=(l+r)/2;
		if(calc(mid)>=0)
			l=mid;
		else
			r=mid;
	}
//	cout<<'R'<<l<<endl;
	return l;
}
ldb getL(ldb peak){
	ldb l=0,r=peak,mid;
	while(r-l>1e-7l){
		mid=(l+r)/2;
		if(calc(mid)>=0)
			r=mid;
		else
			l=mid;
	}
//	cout<<'L'<<l<<endl;
	return l;
}
int main(){
	int i,j,k;
	n=readint();m=readint();
	for(i=0;i<m;++i){
		int u=readint()-1,v=readint()-1,a=readint(),b=readint(),c=readint(),d=readint();
		U.push_back(u);
		V.push_back(v);
		A.push_back(a);
		B.push_back(b);
		C.push_back(c);
		D.push_back(d);
	}
//	cout<<calc(0.33)<<' '<<calc(0.505)<<' '<<calc(0.66)<<' '<<calc(0.99);
	ldb p=getpeak();
	printf("%.10f\n",(double)(getR(p)-getL(p)));
	return 0;
}

#include <bits/stdc++.h>

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

typedef double db;
const db EPS = 1e-9;
const db inf=1e20;
inline int sign(db a) { return a < -EPS ? -1 : a > EPS; }
inline int cmp(db a, db b){ return sign(a-b); }

const int N=101000;
int ts,u[N],v[N],a[N],b[N],c[N],d[N],n,m;
typedef db flowt;
namespace flow {
	const int M=100000,N=1000;
	int y[M],nxt[M],gap[N],fst[N],c[N],pre[N],q[N],dis[N];
	int slope[M];
	flowt f[M];
	int S,T,tot,Tn;
	void init(int s,int t,int tn) {
		tot=1;
		memset(fst,0,sizeof(fst));
		S=s;T=t;Tn=tn;
	}
	void add(int u,int v,int c,flowt c1,flowt c2=0) {
		tot++;y[tot]=v;f[tot]=c1;nxt[tot]=fst[u];fst[u]=tot;
		slope[tot]=c;
		tot++;y[tot]=u;f[tot]=c2;nxt[tot]=fst[v];fst[v]=tot;
		slope[tot]=0;
	}
	flowt sap() {
		int u=S,t=1;flowt flow=0;
		rep(i,0,Tn) c[i]=fst[i],dis[i]=Tn,gap[i]=0;
		q[0]=T;dis[T]=0;pre[S]=0;
		rep(i,0,t) {
			int u=q[i];
			for (int j=fst[u];j;j=nxt[j]) if (dis[y[j]]>dis[u]+1&&fabs(f[j^1])>EPS)
				q[t++]=y[j],dis[y[j]]=dis[u]+1;
		}
		rep(i,0,Tn) gap[dis[i]]++;
		while (dis[S]<=Tn) {
			while (c[u]&&(fabs(f[c[u]])<EPS||dis[y[c[u]]]+1!=dis[u])) c[u]=nxt[c[u]];
			if (c[u]) {
				pre[y[c[u]]]=c[u]^1;
				u=y[c[u]];
				if (u==T) {
					flowt minf=inf;
					for (int p=pre[T];p;p=pre[y[p]]) minf=min(minf,f[p^1]);
					for (int p=pre[T];p;p=pre[y[p]]) f[p^1]-=minf,f[p]+=minf;
					flow+=minf;u=S;
				}
			} else {
				if (!(--gap[dis[u]])) break;
				int mind=Tn;
				c[u]=fst[u];
				for (int j=fst[u];j;j=nxt[j]) if (fabs(f[j])>EPS&&dis[y[j]]<mind)
					mind=dis[y[j]],c[u]=j;
				dis[u]=mind+1;
				gap[dis[u]]++;
				if (u!=S) u=y[pre[u]];
			}
		}
		q[0]=S; t=1;
		rep(i,0,Tn) dis[i]=Tn;
		rep(i,0,t) {
			int u=q[i];
			for (int j=fst[u];j;j=nxt[j]) if (dis[y[j]]>dis[u]+1&&fabs(f[j])>EPS) {
				dis[y[j]]=dis[u]+1;
				q[t++]=y[j];
			}
		}
		ts=0;
		rep(i,0,Tn) for (int j=fst[i];j;j=nxt[j]) if (dis[i]<Tn&&dis[y[j]]>=Tn) {
			ts+=slope[j];
		}
		return flow;
	}
};

db bel[N];
int sl[N];
int check(double t) {
	rep(i,1,n+1) bel[i]=0,sl[i]=0;
	flow::init(0,n+1,n+2);
	rep(i,0,m) {
		db l=a[i]*t+b[i],r=c[i]*t+d[i];
		flow::add(u[i],v[i],c[i]-a[i],r-l);
		bel[u[i]]+=l; bel[v[i]]-=l;
		sl[u[i]]+=a[i]; sl[v[i]]-=a[i];
	}
	db sf=0;
	int ss=0;
	rep(i,1,n+1) if (bel[i]>0) {
		sf+=bel[i]; flow::add(i,n+1,sl[i],bel[i]);
		ss+=sl[i];
	} else flow::add(0,i,-sl[i],-bel[i]);
	db r=flow::sap();
//	printf("%.10f %.10f %.10f %d %d\n",t,r,sf,ts,ss);
	if (ts==ss) {
		if (cmp(r,sf)==-1) return 2;
		else return 1;
	} else if (ts>ss) return 0;
	else return 2;
}
double gao(int ty) {
	double l=0,r=1;
	rep(it,0,60) {
		double md=(l+r)*0.5;
		if (check(md)>=ty) r=md; else l=md;
	}
	return 0.5*(l+r);
}
int main() {
	scanf("%d%d",&n,&m);
	rep(i,0,m) scanf("%d%d%d%d%d%d",u+i,v+i,a+i,b+i,c+i,d+i);
	db l=gao(1),r=gao(2);
	printf("%.10f\n",r-l);
}

#include <bits/stdc++.h>

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

typedef double db;
const db EPS = 1e-9;
const db inf=1e20;
inline int sign(db a) { return a < -EPS ? -1 : a > EPS; }
inline int cmp(db a, db b){ return sign(a-b); }

const int N=101000;
int ts,u[N],v[N],a[N],b[N],c[N],d[N],n,m;
typedef db flowt;
namespace flow {
	const int M=100000,N=1000;
	int y[M],nxt[M],gap[N],fst[N],c[N],pre[N],q[N],dis[N];
	int slope[M];
	flowt f[M];
	int S,T,tot,Tn;
	void init(int s,int t,int tn) {
		tot=1;
		memset(fst,0,sizeof(fst));
		S=s;T=t;Tn=tn;
	}
	void add(int u,int v,int c,flowt c1,flowt c2=0) {
		tot++;y[tot]=v;f[tot]=c1;nxt[tot]=fst[u];fst[u]=tot;
		slope[tot]=c;
		tot++;y[tot]=u;f[tot]=c2;nxt[tot]=fst[v];fst[v]=tot;
		slope[tot]=0;
	}
	flowt sap() {
		int u=S,t=1;flowt flow=0;
		rep(i,0,Tn) c[i]=fst[i],dis[i]=Tn,gap[i]=0;
		q[0]=T;dis[T]=0;pre[S]=0;
		rep(i,0,t) {
			int u=q[i];
			for (int j=fst[u];j;j=nxt[j]) if (dis[y[j]]>dis[u]+1&&fabs(f[j^1])>EPS)
				q[t++]=y[j],dis[y[j]]=dis[u]+1;
		}
		rep(i,0,Tn) gap[dis[i]]++;
		while (dis[S]<=Tn) {
			while (c[u]&&(fabs(f[c[u]])<EPS||dis[y[c[u]]]+1!=dis[u])) c[u]=nxt[c[u]];
			if (c[u]) {
				pre[y[c[u]]]=c[u]^1;
				u=y[c[u]];
				if (u==T) {
					flowt minf=inf;
					for (int p=pre[T];p;p=pre[y[p]]) minf=min(minf,f[p^1]);
					for (int p=pre[T];p;p=pre[y[p]]) f[p^1]-=minf,f[p]+=minf;
					flow+=minf;u=S;
				}
			} else {
				if (!(--gap[dis[u]])) break;
				int mind=Tn;
				c[u]=fst[u];
				for (int j=fst[u];j;j=nxt[j]) if (fabs(f[j])>EPS&&dis[y[j]]<mind)
					mind=dis[y[j]],c[u]=j;
				dis[u]=mind+1;
				gap[dis[u]]++;
				if (u!=S) u=y[pre[u]];
			}
		}
		q[0]=S; t=1;
		rep(i,0,Tn) dis[i]=Tn;
		rep(i,0,t) {
			int u=q[i];
			for (int j=fst[u];j;j=nxt[j]) if (dis[y[j]]>dis[u]+1&&fabs(f[j])>EPS) {
				dis[y[j]]=dis[u]+1;
				q[t++]=y[j];
			}
		}
		ts=0;
		rep(i,0,Tn) for (int j=fst[i];j;j=nxt[j]) if (dis[i]<Tn&&dis[y[j]]>=Tn) ts+=slope[j];
		return flow;
	}
};

db bel[N];
int sl[N];
int check(double t) {
	rep(i,1,n+1) bel[i]=0,sl[i]=0;
	flow::init(0,n+1,n+2);
	rep(i,0,m) {
		db l=a[i]*t+b[i],r=c[i]*t+d[i];
		if (cmp(l,r)==1) {
			if (a[i]>b[i]) return 2;
			else return 0;
		}
		if (l<=0&&r>=0) {
			flow::add(u[i],v[i],c[i],r);
			flow::add(v[i],u[i],-a[i],-l);
		} else if (l>=0) {
			flow::add(u[i],v[i],c[i]-a[i],r-l);
			bel[u[i]]+=l; bel[v[i]]-=l;
			sl[u[i]]+=a[i]; sl[v[i]]-=a[i];
		} else {
			flow::add(v[i],u[i],c[i]-a[i],r-l);
			bel[u[i]]+=r; bel[v[i]]-=r;
			sl[u[i]]+=c[i]; sl[v[i]]-=c[i];
		}
	}
	db sf=0;
	int ss=0;
	rep(i,1,n+1) if (bel[i]>0) {
		sf+=bel[i]; flow::add(i,n+1,sl[i],bel[i]);
		ss+=sl[i];
	} else flow::add(0,i,-sl[i],-bel[i]);
	db r=flow::sap();
//	printf("%.10f %.10f %.10f %d %d\n",t,sf,r,ss,ts);
	if (ts==ss) {
		if (cmp(r,sf)==-1) return 2;
		else return 1;
	} else if (ts>ss) return 0;
	else return 2;
}
double gao(int ty) {
	double l=0,r=1;
	rep(it,0,60) {
		double md=(l+r)*0.5;
		if (check(md)==ty) r=md; else l=md;
	}
	return 0.5*(l+r);
}
int main() {
	scanf("%d%d",&n,&m);
	rep(i,0,m) {
		scanf("%d%d%d%d%d%d",u+i,v+i,a+i,b+i,c+i,d+i);
		if (a[i]==c[i]&&b[i]>d[i]) {
			puts("0");
			return 0;
		}
	}
	db l=gao(1),r=gao(2);
	printf("%.10f\n",r-l);
}

#include <bits/stdc++.h>

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

typedef double db;
const db EPS = 1e-9;
const db inf=1e20;
inline int sign(db a) { return a < -EPS ? -1 : a > EPS; }
inline int cmp(db a, db b){ return sign(a-b); }

const int N=101000;
int ts,u[N],v[N],a[N],b[N],c[N],d[N],n,m;
typedef db flowt;
namespace flow {
	const int M=100000,N=1000;
	int y[M],nxt[M],gap[N],fst[N],c[N],pre[N],q[N],dis[N];
	int slope[M];
	flowt f[M];
	int S,T,tot,Tn;
	void init(int s,int t,int tn) {
		tot=1;
		memset(fst,0,sizeof(fst));
		S=s;T=t;Tn=tn;
	}
	void add(int u,int v,int c,flowt c1,flowt c2=0) {
		tot++;y[tot]=v;f[tot]=c1;nxt[tot]=fst[u];fst[u]=tot;
		slope[tot]=c;
		tot++;y[tot]=u;f[tot]=c2;nxt[tot]=fst[v];fst[v]=tot;
		slope[tot]=0;
	}
	flowt sap() {
		int u=S,t=1;flowt flow=0;
		rep(i,0,Tn) c[i]=fst[i],dis[i]=Tn,gap[i]=0;
		q[0]=T;dis[T]=0;pre[S]=0;
		rep(i,0,t) {
			int u=q[i];
			for (int j=fst[u];j;j=nxt[j]) if (dis[y[j]]>dis[u]+1&&fabs(f[j^1])>EPS)
				q[t++]=y[j],dis[y[j]]=dis[u]+1;
		}
		rep(i,0,Tn) gap[dis[i]]++;
		while (dis[S]<=Tn) {
			while (c[u]&&(fabs(f[c[u]])<EPS||dis[y[c[u]]]+1!=dis[u])) c[u]=nxt[c[u]];
			if (c[u]) {
				pre[y[c[u]]]=c[u]^1;
				u=y[c[u]];
				if (u==T) {
					flowt minf=inf;
					for (int p=pre[T];p;p=pre[y[p]]) minf=min(minf,f[p^1]);
					for (int p=pre[T];p;p=pre[y[p]]) f[p^1]-=minf,f[p]+=minf;
					flow+=minf;u=S;
				}
			} else {
				if (!(--gap[dis[u]])) break;
				int mind=Tn;
				c[u]=fst[u];
				for (int j=fst[u];j;j=nxt[j]) if (fabs(f[j])>EPS&&dis[y[j]]<mind)
					mind=dis[y[j]],c[u]=j;
				dis[u]=mind+1;
				gap[dis[u]]++;
				if (u!=S) u=y[pre[u]];
			}
		}
		q[0]=S; t=1;
		rep(i,0,Tn) dis[i]=Tn;
		dis[S]=0;
		rep(i,0,t) {
			int u=q[i];
			for (int j=fst[u];j;j=nxt[j]) if (dis[y[j]]>dis[u]+1&&fabs(f[j])>EPS) {
				dis[y[j]]=dis[u]+1;
				q[t++]=y[j];
			}
		}
		ts=0;
		rep(i,0,Tn) for (int j=fst[i];j;j=nxt[j]) if (dis[i]<Tn&&dis[y[j]]>=Tn) ts+=slope[j];
		return flow;
	}
};

db bel[N];
int sl[N];
int check(double t) {
	rep(i,1,n+1) bel[i]=0,sl[i]=0;
	flow::init(0,n+1,n+2);
	rep(i,0,m) {
		db l=a[i]*t+b[i],r=c[i]*t+d[i];
		flow::add(u[i],v[i],c[i]-a[i],r-l);
		bel[u[i]]+=l; bel[v[i]]-=l;
		sl[u[i]]+=a[i]; sl[v[i]]-=a[i];
	}
	db sf=0;
	int ss=0;
	rep(i,1,n+1) if (bel[i]>0) {
		sf+=bel[i]; flow::add(i,n+1,sl[i],bel[i]);
		ss+=sl[i];
	} else flow::add(0,i,-sl[i],-bel[i]);
	db r=flow::sap();
	if (ts==ss) {
		if (cmp(r,sf)==-1) return 2;
		else return 1;
	} else if (ts>ss) return 0;
	else return 2;
}
double gao(int ty) {
	double l=0,r=1;
	while (clock()<1.7*CLOCKS_PER_SEC) {
		double md=(l+r)*0.5;
		if (check(md)>=ty) r=md; else l=md;
	}
	return 0.5*(l+r);
}
int main() {
	scanf("%d%d",&n,&m);
	rep(i,0,m) scanf("%d%d%d%d%d%d",u+i,v+i,a+i,b+i,c+i,d+i);
	db l=gao(1),r=gao(2);
	printf("%.10f\n",r-l);
}

#include<bits/stdc++.h>
#define MN 2000
#define S 0
#define T 1001
#define eps 1e-12
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
double d[T+5],in[T+5];
int n,m,q[T+5],head[T+5],cnt,top,c[T+5];
struct Edge{int u,v,a,b,c,d;}s[MN+5];
struct edge{int to,next;double w;}e[100005];
inline void ins(int f,int t,double w)
{
	e[++cnt]=(edge){t,head[f],w};head[f]=cnt;
	e[++cnt]=(edge){f,head[t],0};head[t]=cnt;
}
bool bfs()
{
	for(int i=1;i<=T;++i) d[i]=1e9;int i,j;
	for(d[q[top=i=1]=S]=0;i<=top;++i)
		for(j=c[q[i]]=head[q[i]];j;j=e[j].next)
			if(e[j].w>eps&&d[q[i]]+1<d[e[j].to])
				d[q[++top]=e[j].to]=d[q[i]]+1;
	return d[T]<1e8;
}
double dfs(int x,double f)
{
	if(x==T) return f;double used=0;
	for(int&i=c[x];i;i=e[i].next)
		if(e[i].w>eps&&d[e[i].to]==d[x]+1)
		{
			double w=dfs(e[i].to,min(f-used,e[i].w));
			used+=w;e[i].w-=w;e[i^1].w+=w;
			if(f-used<eps) return f;
		}
	return used;
}
double Solve(double t)
{
	cnt=1;memset(head,0,sizeof(head));
	memset(in,0,sizeof(in));
	for(int i=1;i<=m;++i)
	{
		double l=t*s[i].a+s[i].b,r=t*s[i].c+s[i].d;
		ins(s[i].u,s[i].v,r-l);
		in[s[i].v]+=l;in[s[i].u]-=l;
	}
	double res=0;
	for(int i=1;i<=n;++i)
		if(in[i]>0) res+=in[i],ins(S,i,in[i]);
		else ins(i,T,-in[i]);
	while(bfs()) res-=dfs(S,1e9);
	return res;
}
int main()
{
	n=read();m=read();
	for(int i=1;i<=m;++i)
		s[i].u=read(),s[i].v=read(),
		s[i].a=read(),s[i].b=read(),
		s[i].c=read(),s[i].d=read();
	double l=0,r=1,ok=-1;
	for(int i=1;i<=50;++i)
	{
		double m1=l+(r-l)/3,m2=m1+(r-l)/3;
		double r1=Solve(m1),r2=Solve(m2);
		if(r1<eps) {ok=m1;break;}
		if(r2<eps) {ok=m2;break;}
		if(r1<r2) r=m2; else l=m1;
	}
	if(ok<0) return 0*puts("0");
	l=0,r=ok;double L=ok,R=ok;
	for(int i=1;i<=30;++i)
	{
		double mid=(l+r)*0.5;
		if(Solve(mid)<eps) L=mid,r=mid;
		else l=mid;
	}
	l=ok;r=1;
	for(int i=1;i<=30;++i)
	{
		double mid=(l+r)*0.5;
		if(Solve(mid)<eps) R=mid,l=mid;
		else r=mid;
	}
	printf("%.10lf\n",R-L);
	return 0;
}

#include<bits/stdc++.h>
#define MN 2000
#define S 0
#define T 1001
#define eps 1e-9
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
double d[T+5],in[T+5];
int n,m,q[T+5],head[T+5],cnt,top,c[T+5];
struct Edge{int u,v,a,b,c,d;}s[MN+5];
struct edge{int to,next;double w;}e[100005];
inline void ins(int f,int t,double w)
{
	e[++cnt]=(edge){t,head[f],w};head[f]=cnt;
	e[++cnt]=(edge){f,head[t],0};head[t]=cnt;
}
bool bfs()
{
	for(int i=1;i<=T;++i) d[i]=1e9;int i,j;
	for(d[q[top=i=1]=S]=0;i<=top;++i)
		for(j=c[q[i]]=head[q[i]];j;j=e[j].next)
			if(e[j].w>eps&&d[q[i]]+1<d[e[j].to])
				d[q[++top]=e[j].to]=d[q[i]]+1;
	return d[T]<1e8;
}
double dfs(int x,double f)
{
	if(x==T) return f;double used=0;
	for(int&i=c[x];i;i=e[i].next)
		if(e[i].w>eps&&d[e[i].to]==d[x]+1)
		{
			double w=dfs(e[i].to,min(f-used,e[i].w));
			used+=w;e[i].w-=w;e[i^1].w+=w;
			if(f-used<eps) return f;
		}
	return used;
}
double Solve(double t)
{
	cnt=1;memset(head,0,sizeof(head));
	memset(in,0,sizeof(in));
	for(int i=1;i<=m;++i)
	{
		double l=t*s[i].a+s[i].b,r=t*s[i].c+s[i].d;
		ins(s[i].u,s[i].v,r-l);
		in[s[i].v]+=l;in[s[i].u]-=l;
	}
	double res=0;
	for(int i=1;i<=n;++i)
		if(in[i]>0) res+=in[i],ins(S,i,in[i]);
		else ins(i,T,-in[i]);
	while(bfs()) res-=dfs(S,1e9);
	return res;
}
int main()
{
	n=read();m=read();
	for(int i=1;i<=m;++i)
		s[i].u=read(),s[i].v=read(),
		s[i].a=read(),s[i].b=read(),
		s[i].c=read(),s[i].d=read();
	double l=0,r=1,ok=-1;
	for(int i=1;i<=50;++i)
	{
		double m1=l+(r-l)/3,m2=m1+(r-l)/3;
		double r1=Solve(m1),r2=Solve(m2);
		if(r1<eps) {ok=m1;break;}
		if(r2<eps) {ok=m2;break;}
		if(r1<r2) r=m2; else l=m1;
	}
	if(ok<0) return 0*puts("0");
	l=0,r=ok;double L=ok,R=ok;
	for(int i=1;i<=30;++i)
	{
		double mid=(l+r)*0.5;
		if(Solve(mid)<eps) L=mid,r=mid;
		else l=mid;
	}
	l=ok;r=1;
	for(int i=1;i<=30;++i)
	{
		double mid=(l+r)*0.5;
		if(Solve(mid)<eps) R=mid,l=mid;
		else r=mid;
	}
	printf("%.10lf\n",R-L);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

const int NMAX = 1005;
const int MMAX = 2005;

const double EPS = 1e-7;

template <class CapacityType>
class MaxFlow {
private:
    static constexpr int NIL = -1;
    static constexpr double EPS = 1e-7;

    static constexpr int INF =
    std::numeric_limits<int> :: max() / 2;

    template <class type>
    int cmp(type x) {
        if (-EPS < x and x < EPS)
            return 0;
        return x < 0 ? -1 : 1;
    }

    struct Edge {
        int nod, nxt;
        CapacityType cap;

        Edge() :
        nod(0), nxt(0), cap(0) {};
        Edge(int _nod, int _nxt, CapacityType _cap) :
        nod(_nod), nxt(_nxt), cap(_cap) {};
    }; std::vector<Edge> lst;

    std::vector<bool> oki; int ptr = 0;
    std::vector<int> beg, que, adj, dis;

    bool bfs(const int src, const int dst) {
        std::fill(dis.begin(), dis.end(), (CapacityType)INF);
        dis[src] = 0; que[0] = src;

        for (int qbg = 0, qen = 0; qbg <= qen; ++qbg) {
            const int x = que[qbg];

            for (int it = beg[x]; it != NIL; it = lst[it].nxt) {
                const int y = lst[it].nod;

                if (cmp(lst[it].cap) > 0 and dis[y] == INF)
                    dis[y] = dis[x] + 1, que[++qen] = y;
            }
        }

        return dis[dst] != INF;
    }

    CapacityType dfs(const int x, const int dst, const CapacityType cap) {
        if (!cmp(cap) or x == dst)
            return cap;

        for (; adj[x] != NIL; adj[x] = lst[adj[x]].nxt) {
            const int y = lst[adj[x]].nod;

            if (cmp(lst[adj[x]].cap) > 0 and dis[y] == dis[x] + 1) {
                const CapacityType aux = dfs(y, dst, std::min(cap, lst[adj[x]].cap));

                if (cmp(aux)) {
                    lst[adj[x]].cap -= aux;
                    lst[adj[x] ^ 1].cap += aux;
                    return aux;
                }
            }
        }

        return 0;
    }

    void fill(const int x) {
        oki[x] = true;

        for (int it = beg[x]; it != NIL; it = lst[it].nxt) {
            const int y = lst[it].nod;

            if (cmp(lst[it].cap) > 0 and !oki[y])
                fill(y);
        }
    }
public:
    MaxFlow(int szn, int szm) {
        dis.resize(szn); beg.resize(szn);
        que.resize(szn); adj.resize(szn);
        oki.resize(szn); lst.resize(szm); // m != n

        std::fill(beg.begin(), beg.end(), (int)NIL);
    }

    inline void addDirectedEdge(const int x, const int y, const CapacityType cap) {
        lst[ptr] = Edge(y, beg[x], cap); beg[x] = ptr++;
        lst[ptr] = Edge(x, beg[y],  0 ); beg[y] = ptr++;
    }

    inline void addUndirectedEdge(const int x, const int y, const CapacityType cap) {
        lst[ptr] = Edge(y, beg[x], cap); beg[x] = ptr++;
        lst[ptr] = Edge(x, beg[y], cap); beg[y] = ptr++;
    }

    CapacityType getMaxFlow(const int src, const int dst) {
        CapacityType aux, ans = 0;

        while (bfs(src, dst)) {
            copy(beg.begin(), beg.end(), adj.begin());

            do {
                aux = dfs(src, dst, INF);
                ans += aux;
            } while (cmp(aux));
        }

        return ans;
    }

    CapacityType getMinCut(const int src, const int dst, std::vector<int> &ans) {
        std::fill(oki.begin(), oki.end(), false);
        CapacityType sol = getMaxFlow(src, dst); fill(src);

        ans.clear();
        for (int i = 0; i < oki.size(); ++i)
            if (oki[i]) ans.push_back(i);

        return sol;
    }
};

struct edge {
    int x, y, a, b, c, d; } edl[MMAX];

inline double sign(double x)
{
    if (-EPS < x and x < +EPS)
        return 0;
    return x < 0 ? -1 : 1;
}

double check(double t, int n, int m)
{
    int src = n + 1, dst = n + 2; double sum = 0;
    MaxFlow<double> myNetwork(n + 5, m * 6 + 5);

    for (int i = 1; i <= m; ++i) {
        int x = edl[i].x, y = edl[i].y;
        double le = t * edl[i].a + edl[i].b,
                    ri = t * edl[i].c + edl[i].d;

        sum += le;
        myNetwork.addDirectedEdge(x, y, ri - le);
        myNetwork.addDirectedEdge(src, y, le);
        myNetwork.addDirectedEdge(x, dst, le);
    }

    return sum - myNetwork.getMaxFlow(src, dst);
}

double solve(double le, double ri, int n, int m)
{
    double ans = 0;
    for (int i = 1; i <= 50; ++i) {
        double md = (le + ri) / 2.0;

        if (sign(check(md, n, m)) <= 0) {
            ans += fabs(md - le);
            le = md;
        } else
            ri = md;
    }
    return ans;
}

void debug(void)
{
    MaxFlow<double> myNetwork(4, 6);

    myNetwork.addDirectedEdge(1, 2, 0.5);
    myNetwork.addDirectedEdge(2, 3, 0.3);

    cerr << myNetwork.getMaxFlow(1, 3);

    exit(0);
}

int main(void)
{
   // freopen("test.in", "r", stdin);
   // freopen("test.out", "w", stdout);

    // debug();

    int n, m;
    cin >> n >> m;

    for (int i = 1; i <= m; ++i) {
        cin >> edl[i].x >> edl[i].y;
        cin >> edl[i].a >> edl[i].b >> edl[i].c >> edl[i].d;
    }

    /*
    for (double x = 0.0; x <= 1.00001; x += 0.05) {
        cout << setprecision(2) << fixed << x << " ";
        cout << setprecision(10) << fixed << check(x, n, m) << endl;
    }
    */

    double le = 0.0, ri = 1.0;
    for (int i = 1; i <= 50; ++i) {
        double md1 = le + (ri - le) / 3.0,
        md2 = ri - (ri - le) / 3.0;

        double ans1 = check(md1, n, m),
        ans2 = check(md2, n, m);

        if (sign(ans1) <= 0 and sign(ans2) <= 0) {
            cout << setprecision(10) << fixed;
            cout << solve((md1 + md2) / 2.0, 1.0, n, m) + solve((md1 + md2) / 2.0, 0.0, n, m);
            break;
        }

        if (ans1 < ans2) ri = md2;
        else             le = md1;
    }

    return 0;
}

#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
using namespace std;
typedef long long LL;
const int MAXN = 1005;
const int MAXM = 3005;
const double inf = 1e8;
const double eps = 1e-8;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

int n, m, U[MAXM], V[MAXM], A[MAXM], B[MAXM], C[MAXM], D[MAXM];

struct Edge {
	int v, nxt;
	double w;
} e[MAXM << 1];
int first[MAXN], used[MAXN], eCnt;

inline void AddEdge(int u, int v, double w) {
	e[++eCnt].v = v;
	e[eCnt].w = w;
	e[eCnt].nxt = first[u];
	first[u] = eCnt;
}

inline void Add(int u, int v, double w) {
	AddEdge(u, v, w);
	AddEdge(v, u, 0);
}

double in[MAXN];
int S, T, level[MAXN], q[MAXN], head, tail;

bool BFS() {
	for (int i = 1; i <= T; ++i) {
		level[i] = -1;
		used[i] = first[i];
	}
	level[S] = 0;
	q[head = tail = 1] = S;
	while (head <= tail) {
		int u = q[head++];
		if (u == T) return 1;
		for (int i = first[u]; i; i = e[i].nxt) {
			int v = e[i].v;
			if (e[i].w > eps && level[v] == -1) {
				level[v] = level[u] + 1;
				q[++tail] = v;
			}
		}
	}
	return 0;
}

double DFS(int u, double flow) {
	if (u == T) return flow;
	double ret = 0;
	for (int i = used[u]; i; i = e[i].nxt, used[u] = i) {
		int v = e[i].v;
		if (e[i].w > eps && level[v] == level[u] + 1) {
			double tmp = DFS(v, min(flow, e[i].w));
			e[i].w -= tmp;
			e[i ^ 1].w += tmp;
			flow -= tmp;
			ret += tmp;
			if (flow < eps) break;
		}
	}
	return ret;
}

double Check(double mid) {
	eCnt= 1;
	for (int i = 1; i <= T; ++i) {
		in[i] = first[i] = 0;
	}
	for (int i = 1; i <= m; ++i) {
		double l = mid * A[i] + B[i];
		double r = mid * C[i] + D[i];
		Add(U[i], V[i], r - l);
		in[V[i]] += l;
		in[U[i]] -= l;
	}
	double ret = 0;
	for (int i = 1; i <= n; ++i) {
		if (in[i] > 0) {
			ret += in[i];
			Add(S, i, in[i]);
		} else if (in[i] < 0) {
			Add(i, T, -in[i]);
		}
	}
	while (BFS()) {
		ret -= DFS(S, inf);
	}
	return ret;
}

void init() {
	read(n); read(m);
	for (int i = 1; i <= m; ++i) {
		read(U[i]); read(V[i]);
		read(A[i]); read(B[i]);
		read(C[i]); read(D[i]);
	}
	S = n + 1, T = S + 1;
}

void solve() {
	double L = 0, R = 1, ok = -1;
	while (R - L > eps) {
		double M1 = L + (R - L) / 3, M2 = R - (R - L) / 3;
		double D1 = Check(M1), D2 = Check(M2);
		if (D1 < eps) {
			ok = M1; break;
		}
		if (D2 < eps) {
			ok = M2; break;
		}
		(D1 > D2)? L = D1 : R = D2;
	}
	if (ok < 0) {
		printf("0\n");
		return;
	}
	double L1 = 0, R1 = ok;
	while (R1 - L1 > eps) {
		double M = (L1 + R1) / 2;
		(Check(M) > eps)? L1 = M : R1 = M;
	}
	double L2 = ok, R2 = 1;
	while (R2 - L2 > eps) {
		double M = (L2 + R2) / 2;
		(Check(M) > eps)? R2 = M : L2 = M;
	}
	printf("%.10lf\n", L2 - L1);
}

int main() {
	init();
	solve();
	return 0;
}

#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
using namespace std;
typedef long long LL;
const int MAXN = 1005;
const int MAXM = 3005;
const double inf = 1e8;
const double eps = 1e-8;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

int n, m, U[MAXM], V[MAXM], A[MAXM], B[MAXM], C[MAXM], D[MAXM];

struct Edge {
	int v, nxt;
	double w;
} e[MAXM << 1];
int first[MAXN], used[MAXN], eCnt;

inline void AddEdge(int u, int v, double w) {
	e[++eCnt].v = v;
	e[eCnt].w = w;
	e[eCnt].nxt = first[u];
	first[u] = eCnt;
}

inline void Add(int u, int v, double w) {
	AddEdge(u, v, w);
	AddEdge(v, u, 0);
}

double in[MAXN];
int S, T, level[MAXN], q[MAXN], head, tail;

bool BFS() {
	for (int i = 1; i <= T; ++i) {
		level[i] = -1;
		used[i] = first[i];
	}
	level[S] = 0;
	q[head = tail = 1] = S;
	while (head <= tail) {
		int u = q[head++];
		if (u == T) return 1;
		for (int i = first[u]; i; i = e[i].nxt) {
			int v = e[i].v;
			if (e[i].w > eps && level[v] == -1) {
				level[v] = level[u] + 1;
				q[++tail] = v;
			}
		}
	}
	return 0;
}

double DFS(int u, double flow) {
	if (u == T) return flow;
	double ret = 0;
	for (int i = used[u]; i; i = e[i].nxt, used[u] = i) {
		int v = e[i].v;
		if (e[i].w > eps && level[v] == level[u] + 1) {
			double tmp = DFS(v, min(flow, e[i].w));
			e[i].w -= tmp;
			e[i ^ 1].w += tmp;
			flow -= tmp;
			ret += tmp;
			if (flow < eps) break;
		}
	}
	return ret;
}

double Check(double mid) {
	eCnt= 1;
	for (int i = 1; i <= T; ++i) {
		in[i] = first[i] = 0;
	}
	for (int i = 1; i <= m; ++i) {
		double l = mid * A[i] + B[i];
		double r = mid * C[i] + D[i];
		Add(U[i], V[i], r - l);
		in[V[i]] += l;
		in[U[i]] -= l;
	}
	double ret = 0;
	for (int i = 1; i <= n; ++i) {
		if (in[i] > eps) {
			ret += in[i];
			Add(S, i, in[i]);
		} else if (in[i] < -eps) {
			Add(i, T, -in[i]);
		}
	}
	while (BFS()) {
		ret -= DFS(S, inf);
	}
	return ret;
}

void init() {
	read(n); read(m);
	for (int i = 1; i <= m; ++i) {
		read(U[i]); read(V[i]);
		read(A[i]); read(B[i]);
		read(C[i]); read(D[i]);
	}
	S = n + 1, T = S + 1;
}

void solve() {
	double L = 0, R = 1, ok = -1;
	while (R - L > eps) {
		double M1 = L + (R - L) / 3, M2 = R - (R - L) / 3;
		double D1 = Check(M1), D2 = Check(M2);
		if (D1 < eps) {
			ok = M1; break;
		}
		if (D2 < eps) {
			ok = M2; break;
		}
		(D1 > D2)? L = D1 : R = D2;
	}
	if (ok < 0) {
		printf("0\n");
		return;
	}
	double L1 = 0, R1 = ok;
	while (R1 - L1 > eps) {
		double M = (L1 + R1) / 2;
		(Check(M) > eps)? L1 = M : R1 = M;
	}
	double L2 = ok, R2 = 1;
	while (R2 - L2 > eps) {
		double M = (L2 + R2) / 2;
		(Check(M) > eps)? R2 = M : L2 = M;
	}
	printf("%.8lf\n", L2 - L1);
}

int main() {
	init();
	solve();
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

const int maxn=1005;
const int maxm=2005;
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];
	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]>0&&lvl[to[i]]<0){
				lvl[to[i]]=lvl[x]+1;
				que[qr++]=to[i];
			}
		}
		return lvl[T]>=0;
	}
	double dfs(int x,double f){
		if(x==T)return f;
		for(int &i=cur[x];~i;i=nxt[i])if(cap[i]>0&&lvl[to[i]]==lvl[x]+1){
			double d=dfs(to[i],min(cap[i],f));
			if(d>0){
				cap[i]-=d;
				cap[i^1]+=d;
				return d;
			}
		}
		return 0;
	}
	double work(){
		double res=0;
		while(bfs()){
			for(int i=0;i<V;i++)cur[i]=head[i];
			double f;
			while(f=dfs(S,1e9))res+=f;
		}
		return res;
	}
}

double calc(double t){
	Flow::init();
	Flow::S=0;Flow::T=n+1;Flow::V=Flow::T+2;
	double tot=0;
	for(int i=1;i<=m;i++){
		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;
}
double findP(double l,double r){
	while(r-l>1e-8){
		double midl=l+(r-l)/3,midr=r-(r-l)/3;
		double vall=calc(midl),valr=calc(midr);
		if(vall<valr)l=midl;
		else r=midr;
	}
	return (l+r)/2;
}
double findL(double l,double r){
	while(r-l>1e-8){
		double mid=(l+r)/2;
		if(calc(mid)>=-1e-9)r=mid;
		else l=mid;
	}
	return (l+r)/2;
}
double findR(double l,double r){
	while(r-l>1e-8){
		double mid=(l+r)/2;
		if(calc(mid)>=-1e-9)l=mid;
		else r=mid;
	}
	return (l+r)/2;
}

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]);
	double p=findP(0,1);
	printf("%.10lf\n",findR(p,1)-findL(0,p));
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

const double dinf = 1e100;

template <typename T>
void pfill(T* pst, const T* ped, T val) {
	for ( ; pst != ped; *(pst++) = val);
}

template <typename T>
class Edge {
	public:
		int ed, nx;
		T r;

		Edge(int ed = 0, int nx = 0, T r = 0) : ed(ed), nx(nx), r(r) {	}
};

template <typename T>
class MapManager {
	public:
		int *h;
		vector<Edge<T> > es;

		MapManager() {	}
		MapManager(int n) {
			h = new int[(n + 1)];
			pfill(h, h + n + 1, -1);
		}
		~MapManager() {
			delete[] h;
			es.clear();
		}

		void addEdge(int u, int v, T r) {
			es.push_back(Edge<T>(v, h[u], r));
			h[u] = (signed) es.size() - 1;
		}

		void addArc(int u, int v, T cap) {
			addEdge(u, v, cap);
			addEdge(v, u, 0);
		}

		Edge<T>& operator [] (int p) {
			return es[p];
		}
};

class Dcmp {
	public:
		const static double eps;

		boolean operator () (double x) {
			return fabs(x) >= eps;
		}
} dcmp;

const double Dcmp :: eps = 1e-8;

template <typename Type>
class Network {
	public:
		int S, T;
		int *cur, *div;
		MapManager<Type> g;

		Network() {	}
		Network(int S, int T) : S(S), T(T), g(T + 1) {
			cur = new int[(T + 1)];
			div = new int[(T + 1)];
		}
		~Network() {
			delete[] cur;
			delete[] div;
		}

		boolean bfs() {
			static queue<int> que;
			pfill(div, div + T + 1, -1);
			div[S] = 0;
			que.push(S);
			while (!que.empty()) {
				int e = que.front();
				que.pop();
				for (int i = g.h[e], eu; ~i; i = g[i].nx) {
//					cerr << i << '\n';
					if (!dcmp(g[i].r))
						continue;
					eu = g[i].ed;
					if (!~div[eu]) {
						div[eu] = div[e] + 1;
						que.push(eu);
					}
				}
			}
			return ~div[T];
		}

		Type dfs(int p, Type minf) {
			if (p == T || !dcmp(minf))
				return minf;
			Type flow = 0, f;
			for (int& i = cur[p], e; (~i); i = cur[p], i = g[i].nx) {
				e = g[i].ed;
				if (div[e] == div[p] + 1 && dcmp(f = dfs(e, min(minf, g[i].r))) > 0) {
					flow += f;
					g[i].r -= f;
					g[i ^ 1].r += f;
					minf -= f;
					if (!dcmp(minf)) {
						break;
					}
				}
			}
			return flow;
		}

		Type dinic() {
			Type rt = 0;
//			cerr << g.h[0] << '\n';
			while (bfs()) {
				for (int i = 0; i <= T; i++)
					cur[i] = g.h[i];
				rt += dfs(S, dinf);
			}
			return rt;
		}
};

const int N = 1e3 + 5, M = 2e3 + 5;

int n, m;
Network<double> *network;
int us[M], vs[M], as[M], bs[M], cs[M], ds[M];

inline void init() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d%d%d%d%d%d", us + i, vs + i, as + i, bs + i, cs + i, ds + i);
	}
}

double in[N], out[N];
double build(double t) {
	MapManager<double> &g = network->g;
	for (int i = 1; i <= n; i++) {
		in[i] = out[i] = 0.0;
	}
	double rt = 0;
	for (int i = 0; i < m; i++) {
		double low = as[i] * t + bs[i], dif;
		g[i << 1].r = dif = (cs[i] - as[i]) * t + ds[i] - bs[i];
		g[i << 1 | 1].r = 0.0;
		out[us[i]] += low;
		in[vs[i]] += low;
		rt += low;
//		cerr << us[i] << " " << vs[i] << " " << dif << '\n';
	}
	int s = (m << 1);
	for (int i = 0; i < n; i++, s += 2) {
		g[s].r = in[i + 1];
		g[s | 1].r = 0;
//		cerr << 0 << " " << i + 1 << " " << in[i + 1] << '\n';
	}
	for (int i = 0; i < n; i++, s += 2) {
		g[s].r = out[i + 1];
		g[s | 1].r = 0;
//		cerr << i + 1 << " " << n + 1 << " " << out[i + 1] << '\n';
	}
	return rt;
}

inline void solve() {
	network = new Network<double>(0, n + 1);
	MapManager<double> &g = network->g;
	for (int i = 0; i < m; i++) {
		g.addArc(us[i], vs[i], 0.0);
	}
	for (int i = 0; i < n; i++) {
		g.addArc(0, i + 1, 0.0);
	}
	for (int i = 0; i < n; i++) {
		g.addArc(i + 1, n + 1, 0.0);
	}
	double div_eps = 1e-7;
	double l = 0, r = 1 - div_eps, mid, f1, f2, low;
	for (int _ = 0; l + Dcmp :: eps < r && _ < 64; _++) {
		mid = (l + r) / 2;
		low = build(mid);
		f1 = low - network->dinic();
		low = build(mid + div_eps);
		f2 = low - network->dinic();
		if (!dcmp(f1 - f2)) {
			r = mid;
		} else if (f1 > f2) {
			l = mid;
		} else {
			r = mid;
		}
	}
	double L = r;
	l = L, r = 1 - div_eps;
	for (int _ = 0; l + Dcmp :: eps < r && _ < 64; _++) {
		mid = (l + r) / 2;
		low = build(mid);
		f1 = low - network->dinic();
		low = build(mid + div_eps);
		f2 = low - network->dinic();
		if (!dcmp(f1 - f2)) {
			l = mid;
		} else if (f1 > f2) {
			l = mid;
		} else {
			r = mid;
		}
	}
	low = build(L);
	f1 = low - network->dinic();
	if (dcmp(f1)) {
		puts("0.000000");
	} else {
		printf("%.7lf\n", l - L);
	}
}

int main() {
	init();
	solve();
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

const double dinf = 1e100;

template <typename T>
void pfill(T* pst, const T* ped, T val) {
	for ( ; pst != ped; *(pst++) = val);
}

template <typename T>
class Edge {
	public:
		int ed, nx;
		T r;

		Edge(int ed = 0, int nx = 0, T r = 0) : ed(ed), nx(nx), r(r) {	}
};

template <typename T>
class MapManager {
	public:
		int *h;
		vector<Edge<T> > es;

		MapManager() {	}
		MapManager(int n) {
			h = new int[(n + 1)];
			pfill(h, h + n + 1, -1);
		}
		~MapManager() {
			delete[] h;
			es.clear();
		}

		void addEdge(int u, int v, T r) {
			es.push_back(Edge<T>(v, h[u], r));
			h[u] = (signed) es.size() - 1;
		}

		void addArc(int u, int v, T cap) {
			addEdge(u, v, cap);
			addEdge(v, u, 0);
		}

		Edge<T>& operator [] (int p) {
			return es[p];
		}
};

class Dcmp {
	public:
		const static double eps;

		boolean operator () (double x) {
			return fabs(x) >= eps;
		}
} dcmp;

const double Dcmp :: eps = 5e-8;

template <typename Type>
class Network {
	public:
		int S, T;
		int *cur, *div;
		MapManager<Type> g;

		Network() {	}
		Network(int S, int T) : S(S), T(T), g(T + 1) {
			cur = new int[(T + 1)];
			div = new int[(T + 1)];
		}
		~Network() {
			delete[] cur;
			delete[] div;
		}

		boolean bfs() {
			static queue<int> que;
			pfill(div, div + T + 1, -1);
			div[S] = 0;
			que.push(S);
			while (!que.empty()) {
				int e = que.front();
				que.pop();
				for (int i = g.h[e], eu; ~i; i = g[i].nx) {
//					cerr << i << '\n';
					if (!dcmp(g[i].r))
						continue;
					eu = g[i].ed;
					if (!~div[eu]) {
						div[eu] = div[e] + 1;
						que.push(eu);
					}
				}
			}
			return ~div[T];
		}

		Type dfs(int p, Type minf) {
			if (p == T || !dcmp(minf))
				return minf;
			Type flow = 0, f;
			for (int& i = cur[p], e; (~i); i = cur[p], i = g[i].nx) {
				e = g[i].ed;
				if (div[e] == div[p] + 1 && dcmp(f = dfs(e, min(minf, g[i].r))) > 0) {
					flow += f;
					g[i].r -= f;
					g[i ^ 1].r += f;
					minf -= f;
					if (!dcmp(minf)) {
						break;
					}
				}
			}
			return flow;
		}

		Type dinic() {
			Type rt = 0;
//			cerr << g.h[0] << '\n';
			while (bfs()) {
				for (int i = 0; i <= T; i++)
					cur[i] = g.h[i];
				rt += dfs(S, dinf);
			}
			return rt;
		}
};

const int N = 1e3 + 5, M = 2e3 + 5;

int n, m;
Network<double> *network;
int us[M], vs[M], as[M], bs[M], cs[M], ds[M];

inline void init() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d%d%d%d%d%d", us + i, vs + i, as + i, bs + i, cs + i, ds + i);
	}
}

double in[N], out[N];
double build(double t) {
	MapManager<double> &g = network->g;
	for (int i = 1; i <= n; i++) {
		in[i] = out[i] = 0.0;
	}
	double rt = 0;
	for (int i = 0; i < m; i++) {
		double low = as[i] * t + bs[i], dif;
		g[i << 1].r = dif = (cs[i] - as[i]) * t + ds[i] - bs[i];
		g[i << 1 | 1].r = 0.0;
		out[us[i]] += low;
		in[vs[i]] += low;
		rt += low;
//		cerr << us[i] << " " << vs[i] << " " << dif << '\n';
	}
	int s = (m << 1);
	for (int i = 0; i < n; i++, s += 2) {
		g[s].r = in[i + 1];
		g[s | 1].r = 0;
//		cerr << 0 << " " << i + 1 << " " << in[i + 1] << '\n';
	}
	for (int i = 0; i < n; i++, s += 2) {
		g[s].r = out[i + 1];
		g[s | 1].r = 0;
//		cerr << i + 1 << " " << n + 1 << " " << out[i + 1] << '\n';
	}
	return rt;
}

inline void solve() {
	network = new Network<double>(0, n + 1);
	MapManager<double> &g = network->g;
	for (int i = 0; i < m; i++) {
		g.addArc(us[i], vs[i], 0.0);
	}
	for (int i = 0; i < n; i++) {
		g.addArc(0, i + 1, 0.0);
	}
	for (int i = 0; i < n; i++) {
		g.addArc(i + 1, n + 1, 0.0);
	}
	double div_eps = 5e-6;
	double l = 0, r = 1 - div_eps, mid, f1, f2, low;
	for (int _ = 0; l + Dcmp :: eps < r && _ < 64; _++) {
		mid = (l + r) / 2;
		low = build(mid);
		f1 = low - network->dinic();
		low = build(mid + div_eps);
		f2 = low - network->dinic();
		if (!dcmp(f1 - f2)) {
			r = mid;
		} else if (f1 > f2) {
			l = mid;
		} else {
			r = mid;
		}
	}
	double L = r;
	l = L, r = 1 - div_eps;
	for (int _ = 0; l + Dcmp :: eps < r && _ < 64; _++) {
		mid = (l + r) / 2;
		low = build(mid);
		f1 = low - network->dinic();
		low = build(mid + div_eps);
		f2 = low - network->dinic();
		if (!dcmp(f1 - f2)) {
			l = mid;
		} else if (f1 > f2) {
			l = mid;
		} else {
			r = mid;
		}
	}
	low = build(L);
	f1 = low - network->dinic();
	if (dcmp(f1)) {
		puts("0.000000");
	} else {
		printf("%.7lf\n", l - L);
	}
}

int main() {
	init();
	solve();
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

const double dinf = 1e100;

template <typename T>
void pfill(T* pst, const T* ped, T val) {
	for ( ; pst != ped; *(pst++) = val);
}

template <typename T>
class Edge {
	public:
		int ed, nx;
		T r;

		Edge(int ed = 0, int nx = 0, T r = 0) : ed(ed), nx(nx), r(r) {	}
};

template <typename T>
class MapManager {
	public:
		int *h;
		vector<Edge<T> > es;

		MapManager() {	}
		MapManager(int n) {
			h = new int[(n + 1)];
			pfill(h, h + n + 1, -1);
		}
		~MapManager() {
			delete[] h;
			es.clear();
		}

		void addEdge(int u, int v, T r) {
			es.push_back(Edge<T>(v, h[u], r));
			h[u] = (signed) es.size() - 1;
		}

		void addArc(int u, int v, T cap) {
			addEdge(u, v, cap);
			addEdge(v, u, 0);
		}

		Edge<T>& operator [] (int p) {
			return es[p];
		}
};

class Dcmp {
	public:
		const static double eps;

		boolean operator () (double x) {
			return fabs(x) >= eps;
		}
} dcmp;

const double Dcmp :: eps = 1e-9;

template <typename Type>
class Network {
	public:
		int S, T;
		int *cur, *div;
		MapManager<Type> g;

		Network() {	}
		Network(int S, int T) : S(S), T(T), g(T + 1) {
			cur = new int[(T + 1)];
			div = new int[(T + 1)];
		}
		~Network() {
			delete[] cur;
			delete[] div;
		}

		boolean bfs() {
			static queue<int> que;
			pfill(div, div + T + 1, -1);
			div[S] = 0;
			que.push(S);
			while (!que.empty()) {
				int e = que.front();
				que.pop();
				for (int i = g.h[e], eu; ~i; i = g[i].nx) {
//					cerr << i << '\n';
					if (!dcmp(g[i].r))
						continue;
					eu = g[i].ed;
					if (!~div[eu]) {
						div[eu] = div[e] + 1;
						que.push(eu);
					}
				}
			}
			return ~div[T];
		}

		Type dfs(int p, Type minf) {
			if (p == T || !dcmp(minf))
				return minf;
			Type flow = 0, f;
			for (int& i = cur[p], e; (~i); i = cur[p], i = g[i].nx) {
				e = g[i].ed;
				if (div[e] == div[p] + 1 && dcmp(f = dfs(e, min(minf, g[i].r))) > 0) {
					flow += f;
					g[i].r -= f;
					g[i ^ 1].r += f;
					minf -= f;
					if (!dcmp(minf)) {
						break;
					}
				}
			}
			return flow;
		}

		Type dinic() {
			Type rt = 0;
//			cerr << g.h[0] << '\n';
			while (bfs()) {
				for (int i = 0; i <= T; i++)
					cur[i] = g.h[i];
				rt += dfs(S, dinf);
			}
			return rt;
		}
};

const int N = 1e3 + 5, M = 2e3 + 5;

int n, m;
Network<double> *network;
int us[M], vs[M], as[M], bs[M], cs[M], ds[M];

inline void init() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d%d%d%d%d%d", us + i, vs + i, as + i, bs + i, cs + i, ds + i);
	}
}

double in[N], out[N];
double build(double t) {
	MapManager<double> &g = network->g;
	for (int i = 1; i <= n; i++) {
		in[i] = out[i] = 0.0;
	}
	double rt = 0;
	for (int i = 0; i < m; i++) {
		double low = as[i] * t + bs[i], dif;
		g[i << 1].r = dif = (cs[i] - as[i]) * t + ds[i] - bs[i];
		g[i << 1 | 1].r = 0.0;
		out[us[i]] += low;
		in[vs[i]] += low;
		rt += low;
//		cerr << us[i] << " " << vs[i] << " " << dif << '\n';
	}
	int s = (m << 1);
	for (int i = 0; i < n; i++, s += 2) {
		g[s].r = in[i + 1];
		g[s | 1].r = 0;
//		cerr << 0 << " " << i + 1 << " " << in[i + 1] << '\n';
	}
	for (int i = 0; i < n; i++, s += 2) {
		g[s].r = out[i + 1];
		g[s | 1].r = 0;
//		cerr << i + 1 << " " << n + 1 << " " << out[i + 1] << '\n';
	}
	return rt;
}

inline void solve() {
	network = new Network<double>(0, n + 1);
	MapManager<double> &g = network->g;
	for (int i = 0; i < m; i++) {
		g.addArc(us[i], vs[i], 0.0);
	}
	for (int i = 0; i < n; i++) {
		g.addArc(0, i + 1, 0.0);
	}
	for (int i = 0; i < n; i++) {
		g.addArc(i + 1, n + 1, 0.0);
	}
	double div_eps = 5e-8;
	double l = 0, r = 1 - div_eps, mid, f1, f2, low;
	for (int _ = 0; l + Dcmp :: eps < r && _ < 64; _++) {
		mid = (l + r) / 2;
		low = build(mid);
		f1 = low - network->dinic();
		low = build(mid + div_eps);
		f2 = low - network->dinic();
		if (!dcmp(f1 - f2)) {
			r = mid;
		} else if (f1 > f2) {
			l = mid;
		} else {
			r = mid;
		}
	}
	double L = r;
	l = L, r = 1 - div_eps;
	for (int _ = 0; l + Dcmp :: eps < r && _ < 64; _++) {
		mid = (l + r) / 2;
		low = build(mid);
		f1 = low - network->dinic();
		low = build(mid + div_eps);
		f2 = low - network->dinic();
		if (!dcmp(f1 - f2)) {
			l = mid;
		} else if (f1 > f2) {
			l = mid;
		} else {
			r = mid;
		}
	}
	low = build(L);
	f1 = low - network->dinic();
	if (dcmp(f1)) {
		puts("0.000000");
	} else {
		printf("%.7lf\n", l - L);
	}
}

int main() {
	init();
	solve();
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

const double dinf = 1e100;

template <typename T>
void pfill(T* pst, const T* ped, T val) {
	for ( ; pst != ped; *(pst++) = val);
}

template <typename T>
class Edge {
	public:
		int ed, nx;
		T r;

		Edge(int ed = 0, int nx = 0, T r = 0) : ed(ed), nx(nx), r(r) {	}
};

template <typename T>
class MapManager {
	public:
		int *h;
		vector<Edge<T> > es;

		MapManager() {	}
		MapManager(int n) {
			h = new int[(n + 1)];
			pfill(h, h + n + 1, -1);
		}
		~MapManager() {
			delete[] h;
			es.clear();
		}

		void addEdge(int u, int v, T r) {
			es.push_back(Edge<T>(v, h[u], r));
			h[u] = (signed) es.size() - 1;
		}

		void addArc(int u, int v, T cap) {
			addEdge(u, v, cap);
			addEdge(v, u, 0);
		}

		Edge<T>& operator [] (int p) {
			return es[p];
		}
};

class Dcmp {
	public:
		const static double eps;

		boolean operator () (double x) {
			return fabs(x) >= eps;
		}
} dcmp;

const double Dcmp :: eps = 1e-8;

template <typename Type>
class Network {
	public:
		int S, T;
		int *cur, *div;
		MapManager<Type> g;

		Network() {	}
		Network(int S, int T) : S(S), T(T), g(T + 1) {
			cur = new int[(T + 1)];
			div = new int[(T + 1)];
		}
		~Network() {
			delete[] cur;
			delete[] div;
		}

		boolean bfs() {
			static queue<int> que;
			pfill(div, div + T + 1, -1);
			div[S] = 0;
			que.push(S);
			while (!que.empty()) {
				int e = que.front();
				que.pop();
				for (int i = g.h[e], eu; ~i; i = g[i].nx) {
//					cerr << i << '\n';
					if (!dcmp(g[i].r))
						continue;
					eu = g[i].ed;
					if (!~div[eu]) {
						div[eu] = div[e] + 1;
						que.push(eu);
					}
				}
			}
			return ~div[T];
		}

		Type dfs(int p, Type minf) {
			if (p == T || !dcmp(minf))
				return minf;
			Type flow = 0, f;
			for (int& i = cur[p], e; (~i); i = cur[p], i = g[i].nx) {
				e = g[i].ed;
				if (div[e] == div[p] + 1 && dcmp(f = dfs(e, min(minf, g[i].r))) > 0) {
					flow += f;
					g[i].r -= f;
					g[i ^ 1].r += f;
					minf -= f;
					if (!dcmp(minf)) {
						break;
					}
				}
			}
			return flow;
		}

		Type dinic() {
			Type rt = 0;
//			cerr << g.h[0] << '\n';
			while (bfs()) {
				for (int i = 0; i <= T; i++)
					cur[i] = g.h[i];
				rt += dfs(S, dinf);
			}
			return rt;
		}
};

const int N = 1e3 + 5, M = 2e3 + 5;

int n, m;
Network<double> *network;
int us[M], vs[M], as[M], bs[M], cs[M], ds[M];

inline void init() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d%d%d%d%d%d", us + i, vs + i, as + i, bs + i, cs + i, ds + i);
	}
}

double in[N], out[N];
double build(double t) {
	MapManager<double> &g = network->g;
	for (int i = 1; i <= n; i++) {
		in[i] = out[i] = 0.0;
	}
	double rt = 0;
	for (int i = 0; i < m; i++) {
		double low = as[i] * t + bs[i], dif;
		g[i << 1].r = dif = (cs[i] - as[i]) * t + ds[i] - bs[i];
		g[i << 1 | 1].r = 0.0;
		out[us[i]] += low;
		in[vs[i]] += low;
		rt += low;
//		cerr << us[i] << " " << vs[i] << " " << dif << '\n';
	}
	int s = (m << 1);
	for (int i = 0; i < n; i++, s += 2) {
		g[s].r = in[i + 1];
		g[s | 1].r = 0;
//		cerr << 0 << " " << i + 1 << " " << in[i + 1] << '\n';
	}
	for (int i = 0; i < n; i++, s += 2) {
		g[s].r = out[i + 1];
		g[s | 1].r = 0;
//		cerr << i + 1 << " " << n + 1 << " " << out[i + 1] << '\n';
	}
	return rt;
}

inline void solve() {
	network = new Network<double>(0, n + 1);
	MapManager<double> &g = network->g;
	for (int i = 0; i < m; i++) {
		g.addArc(us[i], vs[i], 0.0);
	}
	for (int i = 0; i < n; i++) {
		g.addArc(0, i + 1, 0.0);
	}
	for (int i = 0; i < n; i++) {
		g.addArc(i + 1, n + 1, 0.0);
	}
	double div_eps = 1e-7;
	double l = 0, r = 1 - div_eps, mid, f1, f2, low;
	for (int _ = 0; l + Dcmp :: eps < r && _ < 64; _++) {
		mid = (l + r) / 2;
		low = build(mid);
		f1 = low - network->dinic();
		low = build(mid + div_eps);
		f2 = low - network->dinic();
		if (!dcmp(f1 - f2)) {
			r = mid;
		} else if (f1 > f2) {
			l = mid;
		} else {
			r = mid;
		}
	}
	double L = r;
	l = L, r = 1 - div_eps;
	for (int _ = 0; l + Dcmp :: eps < r && _ < 64; _++) {
		mid = (l + r) / 2;
		low = build(mid);
		f1 = low - network->dinic();
		low = build(mid + div_eps);
		f2 = low - network->dinic();
		if (!dcmp(f1 - f2)) {
			l = mid;
		} else if (f1 > f2) {
			l = mid;
		} else {
			r = mid;
		}
	}
	printf("%.7lf\n", l - L);
}

int main() {
	init();
	solve();
	return 0;
}

#include<bits/stdc++.h>
#define maxn 10010
using namespace std;
typedef double ldb;
const ldb eps=1e-9;
struct edge{
	int r,nxt;
	ldb w;
}e[maxn<<1];
ldb deg[maxn];
int fr[maxn],to[maxn],n,m,a[maxn],b[maxn],c[maxn],d[maxn];
int q[maxn],l,r,cur[maxn],dep[maxn],head[maxn],esz,S,T;
void addedge(int u,int v,ldb w){
	e[++esz].r=v;e[esz].nxt=head[u];head[u]=esz;e[esz].w=w;
	e[++esz].r=u;e[esz].nxt=head[v];head[v]=esz;e[esz].w=0;
}
bool bfs(){
	for(int i=S;i<=T;++i)cur[i]=head[i],dep[i]=0;
	l=r=0,q[r++]=S,dep[S]=1;
	while(l<r){
		int u=q[l++];
		for(int t=head[u];t;t=e[t].nxt)if(e[t].w>eps&&!dep[e[t].r])
			dep[e[t].r]=dep[u]+1,q[r++]=e[t].r;
	}
	return dep[T]!=0;
}
ldb find(int u,ldb flow){
	if(u==T)return flow;
	ldb used=0,a=0;
	for(int& t=cur[u];t;t=e[t].nxt)if(e[t].w>eps&&dep[e[t].r]==dep[u]+1){
		a=find(e[t].r,min(flow-used,e[t].w));
		used+=a,e[t].w-=a,e[t^1].w+=a;
		if(flow-used<eps)return used;
	}
	if(used<eps)dep[u]=-1;
	return used;
}
ldb dinic(){
	ldb ans=0,a;
	while(bfs())
		while((a=find(S,1e20))>eps)ans+=a;//,printf("[%.9lf]\n",a);
	return ans;
}
ldb sol(ldb t){
	ldb sum=0;
	esz=1,S=0,T=n+1;
	for(int i=S;i<=T;++i)head[i]=0;
	for(int i=1;i<=m;++i){
		ldb l=a[i]*t+b[i],r=c[i]*t+d[i];
		addedge(S,to[i],l);
		addedge(fr[i],T,l);
		addedge(fr[i],to[i],r-l);
		sum+=l;
	}
	return sum-dinic();
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;++i){
	//	fr[i]=rand()%n+1,to[i]=rand()%n+1;
	//	while(fr[i]==to[i])fr[i]=rand()%n+1,to[i]=rand()%n+1;
	//	a[i]=rand()%20,b[i]=rand()%20,c[i]=rand()%20,d[i]=rand()%20+a[i]+c[i];
		scanf("%d%d%d%d%d%d",&fr[i],&to[i],&a[i],&b[i],&c[i],&d[i]);
	}
	ldb l=0,r=1;
	for(int i=0;i<100;++i){
		ldb mid1=(l+l+r)/3,mid2=(l+r+r)/3;
		ldb f1=sol(mid1),f2=sol(mid2);
//		printf("[%d,%.7lf,%.7lf]",i,l,r);
		if(f1>f2)l=mid1;
		else r=mid2;
	}
//	printf("[%.5lf,%.5lf]",l,sol(l));
	ldb l1=0,r1=l;
	for(int i=0;i<80;++i){
		ldb mid=(l1+r1)/2;
		if(sol(mid)<eps)r1=mid;
		else l1=mid;
	}
	ldb l2=l,r2=1;
	for(int i=0;i<80;++i){
		ldb mid=(l2+r2)/2;
		if(sol(mid)<eps)l2=mid;
		else r2=mid;
	}
//	printf("[%.7lf,%.7lf]",l1,l2);
	printf("%.10lf",(l2-l1));
}

#include<bits/stdc++.h>
#define maxn 10010
using namespace std;
typedef double ldb;
const ldb eps=1e-9;
struct edge{
	int r,nxt;
	ldb w;
}e[maxn<<1];
ldb deg[maxn];
int fr[maxn],to[maxn],n,m,a[maxn],b[maxn],c[maxn],d[maxn];
int q[maxn],l,r,cur[maxn],dep[maxn],head[maxn],esz,S,T;
void addedge(int u,int v,ldb w){
	e[++esz].r=v;e[esz].nxt=head[u];head[u]=esz;e[esz].w=w;
	e[++esz].r=u;e[esz].nxt=head[v];head[v]=esz;e[esz].w=0;
}
bool bfs(){
	for(int i=S;i<=T;++i)cur[i]=head[i],dep[i]=0;
	l=r=0,q[r++]=S,dep[S]=1;
	while(l<r){
		int u=q[l++];
		for(int t=head[u];t;t=e[t].nxt)if(e[t].w>eps&&!dep[e[t].r])
			dep[e[t].r]=dep[u]+1,q[r++]=e[t].r;
	}
	return dep[T]!=0;
}
ldb find(int u,ldb flow){
	if(u==T)return flow;
	ldb used=0,a=0;
	for(int& t=cur[u];t;t=e[t].nxt)if(e[t].w>eps&&dep[e[t].r]==dep[u]+1){
		a=find(e[t].r,min(flow-used,e[t].w));
		used+=a,e[t].w-=a,e[t^1].w+=a;
		if(flow-used<eps)return used;
	}
	if(used<eps)dep[u]=-1;
	return used;
}
ldb dinic(){
	ldb ans=0,a;
	while(bfs())
		while((a=find(S,1e20))>eps)ans+=a;//,printf("[%.9lf]\n",a);
	return ans;
}
ldb sol(ldb t){
	ldb sum=0;
	esz=1,S=0,T=n+1;
	for(int i=S;i<=T;++i)head[i]=0;
	for(int i=1;i<=m;++i){
		ldb l=a[i]*t+b[i],r=c[i]*t+d[i];
		addedge(S,to[i],l);
		addedge(fr[i],T,l);
		addedge(fr[i],to[i],r-l);
		sum+=l;
	}
	return sum-dinic();
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;++i){
	//	fr[i]=rand()%n+1,to[i]=rand()%n+1;
	//	while(fr[i]==to[i])fr[i]=rand()%n+1,to[i]=rand()%n+1;
	//	a[i]=rand()%20,b[i]=rand()%20,c[i]=rand()%20,d[i]=rand()%20+a[i]+c[i];
		scanf("%d%d%d%d%d%d",&fr[i],&to[i],&a[i],&b[i],&c[i],&d[i]);
	}
	ldb l=0,r=1;
	for(int i=0;i<50;++i){
		ldb mid1=(l+l+r)/3,mid2=(l+r+r)/3;
		ldb f1=sol(mid1),f2=sol(mid2);
//		printf("[%d,%.7lf,%.7lf]",i,l,r);
		if(f1>f2)l=mid1;
		else r=mid2;
	}
//	printf("[%.5lf,%.5lf]",l,sol(l));
	ldb l1=0,r1=l;
	for(int i=0;i<50;++i){
		ldb mid=(l1+r1)/2;
		if(sol(mid)<eps)r1=mid;
		else l1=mid;
	}
	ldb l2=l,r2=1;
	for(int i=0;i<50;++i){
		ldb mid=(l2+r2)/2;
		if(sol(mid)<eps)l2=mid;
		else r2=mid;
	}
//	printf("[%.7lf,%.7lf]",l1,l2);
	printf("%.10lf",(l2-l1));
}

#include<bits/stdc++.h>
#define maxn 10010
using namespace std;
typedef double ldb;
const ldb eps=1e-12;
struct edge{
	int r,nxt;
	ldb w;
}e[maxn<<1];
ldb deg[maxn];
int fr[maxn],to[maxn],n,m,a[maxn],b[maxn],c[maxn],d[maxn];
int q[maxn],l,r,cur[maxn],dep[maxn],head[maxn],esz,S,T;
void addedge(int u,int v,ldb w){
	e[++esz].r=v;e[esz].nxt=head[u];head[u]=esz;e[esz].w=w;
	e[++esz].r=u;e[esz].nxt=head[v];head[v]=esz;e[esz].w=0;
}
bool bfs(){
	for(int i=S;i<=T;++i)cur[i]=head[i],dep[i]=0;
	l=r=0,q[r++]=S,dep[S]=1;
	while(l<r){
		int u=q[l++];
		for(int t=head[u];t;t=e[t].nxt)if(e[t].w>eps&&!dep[e[t].r])
			dep[e[t].r]=dep[u]+1,q[r++]=e[t].r;
	}
	return dep[T]!=0;
}
ldb find(int u,ldb flow){
	if(u==T)return flow;
	ldb used=0,a=0;
	for(int& t=cur[u];t;t=e[t].nxt)if(e[t].w>eps&&dep[e[t].r]==dep[u]+1){
		a=find(e[t].r,min(flow-used,e[t].w));
		used+=a,e[t].w-=a,e[t^1].w+=a;
		if(flow==used)return used;
	}
	return used;
}
ldb dinic(){
	ldb ans=0,a;
	while(bfs())ans+=find(S,1e20);//,printf("[%.9lf]\n",a);
	return ans;
}
ldb sol(ldb t){
	ldb sum=0;
	esz=1,S=0,T=n+1;
	for(int i=S;i<=T;++i)head[i]=deg[i]=0;
	for(int i=1;i<=m;++i){
		ldb l=a[i]*t+b[i],r=c[i]*t+d[i];
		deg[to[i]]+=l;
		deg[fr[i]]-=l;
		addedge(fr[i],to[i],r-l);
	}
	for(int i=1;i<=n;++i)
		if(deg[i]>0)sum+=deg[i],addedge(S,i,deg[i]);
		else addedge(i,T,-deg[i]);
	return sum-dinic();
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;++i){
	//	fr[i]=rand()%n+1,to[i]=rand()%n+1;
	//	while(fr[i]==to[i])fr[i]=rand()%n+1,to[i]=rand()%n+1;
	//	a[i]=rand()%20,b[i]=rand()%20,c[i]=rand()%20,d[i]=rand()%20+a[i]+c[i];
		scanf("%d%d%d%d%d%d",&fr[i],&to[i],&a[i],&b[i],&c[i],&d[i]);
	}
	ldb l=0,r=1;
	for(int i=0;i<200;++i){
		ldb mid1=(l+l+r)/3,mid2=(l+r+r)/3;
		ldb f1=sol(mid1),f2=sol(mid2);
		if(f1>f2)l=mid1;
		else r=mid2;
	}
	ldb l1=0,r1=l;
	for(int i=0;i<100;++i){
		ldb mid=(l1+r1)/2;
		if(sol(mid)<eps)r1=mid;
		else l1=mid;
	}
	ldb l2=l,r2=1;
	for(int i=0;i<100;++i){
		ldb mid=(l2+r2)/2;
		if(sol(mid)<eps)l2=mid;
		else r2=mid;
	}
	printf("%.10lf",(l2-l1));
}

#include<bits/stdc++.h>
#define maxn 10010
using namespace std;
typedef double ldb;
const ldb eps=1e-9;
struct edge{
	int r,nxt;
	ldb w;
}e[maxn<<1];
ldb deg[maxn];
int fr[maxn],to[maxn],n,m,a[maxn],b[maxn],c[maxn],d[maxn];
int q[maxn],l,r,cur[maxn],dep[maxn],head[maxn],esz,S,T;
void addedge(int u,int v,ldb w){
	e[++esz].r=v;e[esz].nxt=head[u];head[u]=esz;e[esz].w=w;
	e[++esz].r=u;e[esz].nxt=head[v];head[v]=esz;e[esz].w=0;
}
bool bfs(){
	for(int i=S;i<=T;++i)cur[i]=head[i],dep[i]=0;
	l=r=0,q[r++]=S,dep[S]=1;
	while(l<r){
		int u=q[l++];
		for(int t=head[u];t;t=e[t].nxt)if(e[t].w>eps&&!dep[e[t].r])
			dep[e[t].r]=dep[u]+1,q[r++]=e[t].r;
	}
	return dep[T]!=0;
}
ldb find(int u,ldb flow){
	if(u==T)return flow;
	ldb used=0,a=0;
	for(int& t=cur[u];t;t=e[t].nxt)if(e[t].w>eps&&dep[e[t].r]==dep[u]+1){
		a=find(e[t].r,min(flow-used,e[t].w));
		used+=a,e[t].w-=a,e[t^1].w+=a;
		if(flow-used<eps)return used;
	}
	if(used<eps)dep[u]=-1;
	return used;
}
ldb dinic(){
	ldb ans=0,a;
	while(bfs())
		while((a=find(S,1e20))>eps)ans+=a;//,printf("[%.9lf]\n",a);
	return ans;
}
ldb sol(ldb t){
	ldb sum=0;
	esz=1,S=0,T=n+1;
	for(int i=S;i<=T;++i)head[i]=0;
	for(int i=1;i<=m;++i){
		ldb l=a[i]*t+b[i],r=c[i]*t+d[i];
		addedge(S,to[i],l);
		addedge(fr[i],T,l);
		addedge(fr[i],to[i],r-l);
		sum+=l;
	}
	return sum-dinic();
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;++i){
	//	fr[i]=rand()%n+1,to[i]=rand()%n+1;
	//	while(fr[i]==to[i])fr[i]=rand()%n+1,to[i]=rand()%n+1;
	//	a[i]=rand()%20,b[i]=rand()%20,c[i]=rand()%20,d[i]=rand()%20+a[i]+c[i];
		scanf("%d%d%d%d%d%d",&fr[i],&to[i],&a[i],&b[i],&c[i],&d[i]);
	}
	ldb l=0,r=1;
	for(int i=0;i<200;++i){
		ldb mid1=(l+l+r)/3,mid2=(l+r+r)/3;
		ldb f1=sol(mid1),f2=sol(mid2);
		if(f1>f2)l=mid1;
		else r=mid2;
	}
	ldb l1=0,r1=l;
	for(int i=0;i<100;++i){
		ldb mid=(l1+r1)/2;
		if(sol(mid)<eps)r1=mid;
		else l1=mid;
	}
	ldb l2=l,r2=1;
	for(int i=0;i<100;++i){
		ldb mid=(l2+r2)/2;
		if(sol(mid)<eps)l2=mid;
		else r2=mid;
	}
	printf("%.10lf",(l2-l1));
}