2 2
1 2 1 4 2 4
1 2 3 4 4 4
 2 2
1 2 0 9998 0 9999
2 1 0 9999 0 10000
 3 3
1 2 0 3 -4 7
2 3 -2 5 1 6
3 1 0 4 0 4
 2 2
1 2 0 3 0 3
2 1 0 4 0 4
 2 2
1 2 0 0 0 0
2 1 0 0 0 0
 5 10
4 3 -19 49 -11 65
4 4 50 12 -2 65
1 5 56 8 -5 76
5 1 -28 33 -38 49
4 2 0 0 2 9
4 2 0 0 14 8
3 1 26 67 15 85
5 3 -51 98 -44 99
1 3 -33 65 -20 65
3 4 30 6 -30 70
 5 10
4 3 -8 16 -29 72
4 4 -62 65 33 65
1 5 -58 97 -17 97
5 1 -5 10 -68 88
4 2 0 0 -9 60
4 2 0 0 -23 39
3 1 3 28 13 87
5 3 -1 25 -15 90
1 3 -12 33 6 94
3 4 -71 86 -39 86
 5 10
4 3 -1 5 -6 98
4 4 12 14 -43 98
1 5 -4 6 8 88
5 1 0 0 -9 100
4 2 0 0 6 50
4 2 0 0 -39 77
3 1 1 4 -1 100
5 3 -7 13 9 88
1 3 2 0 -7 100
3 4 2 0 3 88
 2 2
1 1 0 4 0 5
2 2 4 0 5 0
 2 2
1 2 0 4 0 4
2 1 0 4 0 4
 2 2
1 2 0 3 0 5
2 1 0 4 0 6

0
 1.0000000000
 0.2500000000
 0
 1.0000000000
 0.2121212000
 0.6666666000
 1.0000000000
 1.0000000000
 1.0000000000
 1.0000000000

#include <bits/stdc++.h>
inline int pidorand() { return ((rand() & 32767) << 15) | (rand() & 32767); }
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;
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));
    }
    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;
}
