#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline T1 max(T1 a, T2 b) {
  return a < b ? b : a;
}
template <typename T1, typename T2>
inline T1 min(T1 a, T2 b) {
  return a < b ? a : b;
}
const char lf = '\n';
namespace ae86 {
const int bufl = 1 << 15;
char buf[bufl], *s = buf, *t = buf;
inline int fetch() {
  if (s == t) {
    t = (s = buf) + fread(buf, 1, bufl, stdin);
    if (s == t) return EOF;
  }
  return *s++;
}
inline int ty() {
  int a = 0;
  int b = 1, c = fetch();
  while (!isdigit(c)) b ^= c == '-', c = fetch();
  while (isdigit(c)) a = a * 10 + c - 48, c = fetch();
  return b ? a : -a;
}
}  // namespace ae86
using ae86::ty;
const int _ = 100007, __ = _ << 1;
const long double eps = 1e-13, inf = 1e99;
inline int dcmp(long double x) {
  if (-eps < x && x < eps) return 0;
  return x > 0 ? 1 : -1;
}
int to[__], ne[__], he[_] = {0}, ecnt = 1;
inline void adde(int a, int b) {
  to[++ecnt] = b, ne[ecnt] = he[a], he[a] = ecnt;
}
inline void addde(int a, int b) { adde(a, b), adde(b, a); }
int fa[_] = {0}, dep[_] = {0}, sz[_] = {0}, mxch[_] = {0};
void dfs(int x, int ff) {
  fa[x] = ff, dep[x] = dep[ff] + 1, sz[x] = 1, mxch[x] = 0;
  for (int i = he[x]; i; i = ne[i]) {
    int b = to[i];
    if (b == ff) continue;
    dfs(b, x), sz[x] += sz[b];
    if (sz[mxch[x]] < sz[b]) mxch[x] = b;
  }
}
int dfn[_] = {0}, dcnt = 0, top[_] = {0};
void dfs2(int x, int tp) {
  dfn[x] = ++dcnt, top[x] = tp;
  if (mxch[x]) dfs2(mxch[x], tp);
  for (int i = he[x]; i; i = ne[i]) {
    int b = to[i];
    if (b == fa[x] || b == mxch[x]) continue;
    dfs2(b, b);
  }
}
int lca(int a, int b) {
  while (top[a] != top[b]) {
    if (dep[top[a]] < dep[top[b]]) swap(a, b);
    a = fa[top[a]];
  }
  if (dep[a] > dep[b]) swap(a, b);
  return a;
}
inline int distan(int a, int b) { return dep[a] + dep[b] - 2 * dep[lca(a, b)]; }
inline int distan(int a, int b, int c) { return dep[a] + dep[b] - 2 * dep[c]; }
long double now;
struct cxk {
  long double st, ta;
  int bas, spd, dir;
  cxk(long double st_ = 0, long double ta_ = 0, int bas_ = 0, int spd_ = 0,
      int dir_ = 0) {
    st = st_, ta = ta_, bas = bas_, spd = spd_, dir = dir_;
  }
  long double f(long double x) { return bas + (x - st) * spd; }
  friend bool operator<(cxk a, cxk b) {
    long double fa = a.f(now), fb = b.f(now);
    if (dcmp(fa - fb) == 0) return a.spd < b.spd;
    return fa < fb;
  }
};
long double cxkdlq(cxk a, cxk b) {
  long double pa = a.f(now), pb = b.f(now);
  if (dcmp(a.spd - b.spd) == 0) return dcmp(pa - pb) == 0 ? 0 : inf;
  long double tim = (pa - pb) / (b.spd - a.spd);
  if (dcmp(tim) >= 0 && dcmp(now + tim - min(a.ta, b.ta)) <= 0) return tim;
  return inf;
}
vector<cxk> dlq[_];
int n, m;
void dreamin(int fr, long double st, long double ta, int spd, int deep) {
  if (st > ta)
    st += eps, ta -= eps;
  else
    st -= eps, ta += eps;
  dlq[fr].emplace_back(st, ta, deep, spd, st < ta);
  dlq[fr].emplace_back(ta, st, deep, spd, ta < st);
}
void pusheen(int st, int spd, int a, int b) {
  int c = lca(a, b);
  long double ta = st + 1.00 * distan(a, b, c) / spd;
  long double frt = st;
  while (top[a] != top[c]) {
    long double co = 1.00 * (dep[a] - dep[fa[top[a]]]) / spd;
    dreamin(top[a], frt, frt + co, -spd, dep[a]), a = fa[top[a]], frt += co;
  }
  long double tot = ta;
  while (top[b] != top[c]) {
    long double co = -1.00 * (dep[b] - dep[fa[top[b]]]) / spd;
    dreamin(top[b], tot, tot + co, spd, dep[fa[top[b]]]), b = fa[top[b]],
                                                          tot += co;
  }
  dreamin(top[c], frt, tot, dep[a] < dep[b] ? spd : -spd, dep[a]);
}
int ed[_] = {0};
long double ans = inf;
void make(int x) {
  ed[x] = 1;
  sort(dlq[x].begin(), dlq[x].end(), [](cxk a, cxk b) {
    if (a.st != b.st) return a.st < b.st;
    return a.dir > b.dir;
  });
  multiset<cxk> s;
  for (auto a : dlq[x]) {
    now = a.st;
    if (now >= ans) break;
    if (a.dir) {
      auto b = s.lower_bound(a);
      if (b != s.end()) ans = min(ans, now + cxkdlq(a, *b));
      if (b != s.begin()) b--, ans = min(ans, now + cxkdlq(a, *b));
      s.emplace(a);
    } else {
      swap(a.st, a.ta), s.erase(s.find(a));
      auto b = s.lower_bound(a), c = b;
      if (b != s.begin() && c != s.end())
        b--, ans = min(ans, now + cxkdlq(*b, *c));
    }
  }
}
int main() {
  ios::sync_with_stdio(0), cout.tie(nullptr);
  n = ty(), m = ty();
  for (int i = 1, a, b; i < n; i++) a = ty(), b = ty(), addde(a, b);
  dfs(1, 0), dfs2(1, 1);
  for (int i = 1, a, b, c, d; i <= m; i++)
    a = ty(), b = ty(), c = ty(), d = ty(), pusheen(a, b, c, d);
  for (int i = 1; i <= n; i++)
    if (!ed[top[i]]) make(top[i]);
  if (ans >= inf)
    cout << -1 << lf;
  else
    cout << setprecision(12) << fixed << ans << lf;
  return 0;
}
