#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const double eps = 1e-9;
inline int O(double x) { return x < -eps ? -1 : (x > eps ? 1 : 0); }
inline int read() {
  int x = 0;
  char c = getchar();
  for (; c < '0' || c > '9'; c = getchar())
    ;
  for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + (c ^ 48);
  return x;
}
int n, m, en, head[maxn];
double T, MXT;
struct edge {
  int v, n;
} e[maxn << 1];
inline void addedge(int u, int v) {
  e[en].v = v;
  e[en].n = head[u];
  head[u] = en++;
  e[en].v = u;
  e[en].n = head[v];
  head[v] = en++;
}
void input() {
  int i;
  n = read();
  m = read();
  en = 2;
  for (i = 1; i < n; i++) addedge(read(), read());
}
int fa[maxn], siz[maxn], son[maxn], top[maxn], dep[maxn];
void dfs(int x, int f) {
  int i;
  siz[x] = 1;
  fa[x] = f;
  for (i = head[x]; i; i = e[i].n)
    if (e[i].v ^ f) {
      dep[e[i].v] = dep[x] + 1;
      dfs(e[i].v, x);
      if (siz[son[x]] < siz[e[i].v]) son[x] = e[i].v;
      siz[x] += siz[e[i].v];
    }
}
void dfs2(int x) {
  int i;
  if (son[x]) top[son[x]] = top[x], dfs2(son[x]);
  for (i = head[x]; i; i = e[i].n)
    if (e[i].v ^ fa[x] && e[i].v ^ son[x]) top[e[i].v] = e[i].v, dfs2(e[i].v);
}
struct li {
  double st, et, sy, dy;
  li() {}
  li(double st, double et, double sy, double dy)
      : st(st), et(et), sy(sy), dy(dy) {}
  bool operator<(const li& s) const {
    return O((sy + (T - st) * dy) - (s.sy + (T - s.st) * s.dy)) < 0;
  }
  double operator*(const li& s) const {
    if (!O(dy - s.dy)) {
      return !O(sy - s.sy) && !O(st - s.st) ? st : 1e200;
    }
    double t = (s.sy - sy + st * dy - s.st * s.dy) / (dy - s.dy);
    return (O(t - max(st, s.st)) >= 0 && O(t - min(et, s.et)) <= 0 ? t : 1e200);
  }
};
vector<li> V[maxn];
inline int lca(int x, int y) {
  while (top[x] ^ top[y]) {
    if (dep[top[x]] < dep[top[y]]) swap(x, y);
    x = fa[top[x]];
  }
  return dep[x] < dep[y] ? x : y;
}
void tag(double t, double c, int a, int b) {
  int z = lca(a, b);
  double d = dep[a] + dep[b] - 2 * dep[z];
  while (1) {
    if (top[a] == top[b]) {
      double dis = dep[b] - dep[a];
      V[top[a]].push_back(li(t, t + abs(dis) / c, dep[a], O(dis) * c));
      return;
    }
    if (dep[top[a]] > dep[top[b]]) {
      double dis = dep[fa[top[a]]] - dep[a];
      V[top[a]].push_back(li(t, t + abs(dis) / c, dep[a], O(dis) * c));
      t += abs(dis) / c;
      d -= abs(dis);
      a = fa[top[a]];
    } else {
      double dis = dep[b] - dep[fa[top[b]]];
      V[top[b]].push_back(
          li(t + (d - dis) / c, t + d / c, dep[fa[top[b]]], O(dis) * c));
      d -= abs(dis);
      b = fa[top[b]];
    }
  }
}
inline bool cmpst(const li& a, const li& b) { return a.st < b.st; }
void pre() {
  int i, a, b;
  double t, c;
  dep[1] = 0;
  dfs(1, 0);
  top[1] = 1;
  dfs2(1);
  for (i = 0; i < m; i++)
    t = read(), c = read(), a = read(), b = read(), tag(t, c, a, b);
  for (i = 1; i <= n; i++)
    if (top[i] == i) sort(V[i].begin(), V[i].end(), cmpst);
}
multiset<li> S;
void L_check(int x) {
  int i;
  multimap<double, li> M;
  S.clear();
  M.clear();
  V[x].push_back(li(1e200, 0, 0, 0));
  for (i = 0; i < (int)V[x].size(); i++) {
    while (M.size() && O(M.begin()->first - V[x][i].st) < 0) {
      T = M.begin()->first;
      if (O(T - MXT) >= 0) break;
      multiset<li>::iterator it = S.find(M.begin()->second), pit = it, sit = it;
      assert(it != S.end());
      if (it != S.begin() && (++sit) != S.end())
        MXT = min(MXT, *(--pit) * (*sit));
      S.erase(it);
      M.erase(M.begin());
    }
    T = V[x][i].st;
    if (O(T - MXT) >= 0) break;
    S.insert(V[x][i]);
    multiset<li>::iterator it = S.find(V[x][i]), pit = it, sit = it;
    assert(it != S.end());
    if (it != S.begin()) MXT = min(MXT, *(--pit) * V[x][i]);
    if ((++sit) != S.end()) MXT = min(MXT, *sit * V[x][i]);
    M.insert(make_pair(min(V[x][i].et, MXT), V[x][i]));
  }
}
void solve() {
  MXT = 1e10;
  int i;
  for (i = 1; i <= n; i++)
    if (top[i] == i) {
      L_check(i);
    }
  if (MXT >= 1e10) puts("-1"), exit(0);
  printf("%.6lf\n", MXT);
}
int main() {
  input();
  pre();
  solve();
  return 0;
}
