#include <bits/stdc++.h>
using namespace std;
namespace TYC {
const int N = 1e5 + 5;
const long double eps = 1e-12, INF = 1e100;
int n, m, dep[N], top[N], fa[N], size[N], son[N];
long double tim, ans = INF;
vector<int> E[N];
struct event {
  long double k, b, s, t;
};
vector<event> heavy[N], light[N];
multiset<event> S;
inline bool equal(const long double &a, const long double &b) {
  return fabs(a - b) < eps;
}
inline bool geq(const long double &a, const long double &b) {
  return a > b || equal(a, b);
}
inline bool leq(const long double &a, const long double &b) {
  return a < b || equal(a, b);
}
inline bool cmp(const pair<event, bool> &p, const pair<event, bool> &q) {
  long double a = p.second ? p.first.s : p.first.t;
  long double b = q.second ? q.first.s : q.first.t;
  return equal(a, b) ? p.second > q.second : a < b;
}
inline bool operator<(const event &p, const event &q) {
  if (equal(p.k * tim + p.b, q.k * tim + q.b)) {
    if (equal(p.s, q.s))
      return equal(p.t, q.t) ? p.k < q.k : p.t < q.t;
    else
      return p.s < q.s;
  } else
    return p.k * tim + p.b < q.k * tim + q.b;
}
void dfs(const int u) {
  size[u] = 1;
  for (int v : E[u])
    if (v != fa[u]) {
      dep[v] = dep[fa[v] = u] + 1;
      dfs(v);
      size[u] += size[v];
      if (size[v] > size[son[u]]) son[u] = v;
    }
}
void dfs(const int u, const int ance) {
  top[u] = ance;
  if (son[u]) dfs(son[u], ance);
  for (int v : E[u])
    if (v != fa[u] && v != son[u]) dfs(v, v);
}
inline int LCA(int u, int v) {
  while (top[u] != top[v]) {
    if (dep[top[u]] < dep[top[v]]) swap(u, v);
    u = fa[top[u]];
  }
  return dep[u] < dep[v] ? u : v;
}
inline int dist(const int u, const int v) {
  return dep[u] + dep[v] - dep[LCA(u, v)] * 2;
}
void upload(int u, int v, long double s, long double c) {
  long double t = s + dist(u, v) / c;
  while (top[u] != top[v]) {
    if (dep[top[u]] > dep[top[v]]) {
      int p = top[u];
      heavy[p].push_back({-c, dep[u] + c * s, s, s + (dep[u] - dep[p]) / c});
      s += (dep[u] - dep[p]) / c;
      light[p].push_back({-c, dep[p] + c * s, s, s + 1 / c});
      s += 1 / c;
      u = fa[p];
    } else {
      int p = top[v];
      heavy[p].push_back({c, dep[v] - c * t, t - (dep[v] - dep[p]) / c, t});
      t -= (dep[v] - dep[p]) / c;
      light[p].push_back({c, dep[p] - c * t, t - 1 / c, t});
      t -= 1 / c;
      v = fa[p];
    }
  }
  int p = top[u];
  if (dep[u] > dep[v])
    heavy[p].push_back({-c, dep[u] + c * s, s, t});
  else
    heavy[p].push_back({c, dep[v] - c * t, s, t});
}
long double cross(const event &p, const event &q) {
  if (equal(p.k, q.k)) {
    if (equal(p.b, q.b))
      return max(p.s, q.s);
    else
      return INF;
  }
  long double t = (q.b - p.b) / (p.k - q.k);
  return (leq(max(p.s, q.s), t) && leq(t, min(p.t, q.t))) ? t : INF;
}
void solve(vector<event> &tmp) {
  static vector<pair<event, bool> > V;
  V.clear();
  S.clear();
  for (auto p : tmp) {
    V.push_back({p, true});
    V.push_back({p, false});
  }
  sort(V.begin(), V.end(), cmp);
  long double goal = INF;
  int cnt = 0;
  for (auto p : V) {
    tim = p.second ? p.first.s : p.first.t;
    if (geq(tim, goal)) return void(ans = min(ans, goal));
    if (p.second) {
      multiset<event>::iterator t = S.insert(p.first), pre = t, nxt = t;
      if (pre != S.begin()) goal = min(goal, cross(*(--pre), *t));
      if (++nxt != S.end()) goal = min(goal, cross(*nxt, *t));
    } else {
      multiset<event>::iterator t = S.lower_bound(p.first), pre = t, nxt = t;
      if (++nxt != S.end() && pre != S.begin())
        goal = min(goal, cross(*(--pre), *nxt));
      S.erase(t);
    }
  }
}
void work() {
  scanf("%d%d", &n, &m);
  for (int i = 1, u, v; i < n; i++) {
    scanf("%d%d", &u, &v);
    E[u].push_back(v);
    E[v].push_back(u);
  }
  dfs(1);
  dfs(1, 1);
  for (int i = 1, t, c, u, v; i <= m; i++) {
    scanf("%d%d%d%d", &t, &c, &u, &v);
    upload(u, v, (long double)t, (long double)c);
  }
  for (int i = 1; i <= n; i++) {
    solve(heavy[i]);
    solve(light[i]);
  }
  if (geq(ans, INF))
    puts("-1");
  else
    printf("%.10f\n", (double)ans);
}
}  // namespace TYC
int main() {
  TYC::work();
  return 0;
}
