#include <bits/stdc++.h>
using namespace std;
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 << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
int n, m, fa[200005], dep[200005], son[200005], top[200005], siz[200005];
vector<int> G[200005];
struct line {
  int x, id, f;
  double t, c;
} be[200005];
double t, c[200005], ed[200005], ans = 1e10;
double calc(const line& x) { return dep[x.x] + (t - x.t) * c[x.id]; }
bool operator<(const line& a, const line& b) { return calc(a) < calc(b); }
void dfs(int x, int f) {
  fa[x] = f;
  dep[x] = dep[f] + 1;
  siz[x] = 1;
  int sizz = G[x].size();
  for (int i = 0; i < sizz; i++) {
    int v = G[x][i];
    if (v == f) continue;
    dfs(v, x);
    siz[x] += siz[v];
    if (siz[v] > siz[son[x]]) son[x] = v;
  }
}
void dfs2(int x, int fath) {
  top[x] = fath;
  int sizz = G[x].size();
  if (son[x]) dfs2(son[x], fath);
  for (int i = 0; i < sizz; i++) {
    int v = G[x][i];
    if (v == fa[x] || v == son[x]) continue;
    dfs2(v, v);
  }
}
double Get(int u, int v, double sp) {
  return (double)abs(dep[u] - dep[v]) / sp;
}
int lca(int x, int y) {
  while (top[x] != top[y]) {
    if (dep[top[y]] > dep[top[x]]) swap(x, y);
    x = fa[top[x]];
  }
  if (dep[x] < dep[y])
    return x;
  else
    return y;
}
multiset<line> st;
vector<line> h[200005];
void update(const line& x, const line& y) {
  double v = calc(y) - calc(x),
         p = fabs(v) < (double)1e-10
                 ? 0
                 : (calc(y) - calc(x)) / (c[x.id] - c[y.id]);
  if (p > -(double)1e-10 && p + t < min(ed[x.id], ed[y.id]) + (double)1e-10)
    ans = min(ans, p + t);
}
int cmp(const line& a, const line& b) {
  return fabs(a.t - b.t) < (double)1e-10 ? a.f > b.f : a.t < b.t;
}
void work(int u) {
  st.clear();
  sort(h[u].begin(), h[u].end(), cmp);
  int sizz = h[u].size();
  for (int i = 0; i < sizz; i++) {
    line x = h[u][i];
    if (x.f)
      be[x.id] = x;
    else
      ed[x.id] = x.t;
  }
  for (int i = 0; i < sizz; i++) {
    line x = h[u][i];
    if ((t = x.t) > ans + (double)1e-10) break;
    if (x.f) {
      st.insert(x);
      set<line>::iterator it = st.find(x);
      c[x.id] = x.c;
      if (it != st.begin()) update(x, *prev(it));
      if (++it != st.end()) update(x, *it);
    } else {
      set<line>::iterator it = st.find(be[x.id]);
      if (it != st.begin() && next(it) != st.end())
        update(*prev(it), *next(it));
      if (it != st.end()) st.erase(it);
    }
  }
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i < n; i++) {
    int x = read(), y = read();
    G[x].push_back(y);
    G[y].push_back(x);
  }
  dfs(1, 0);
  dfs2(1, 1);
  for (int i = 1; i <= m; i++) {
    double t = read();
    c[i] = read();
    int x = read(), y = read(), u = x, v = y, p = lca(u, v), flag = 1;
    double T = t + Get(u, p, c[i]);
    while (top[u] != top[v]) {
      if (dep[top[u]] < dep[top[v]]) swap(u, v), flag ^= 1;
      if (flag)
        h[top[u]].push_back((line){u, i, 1, t + Get(x, u, c[i]), -c[i]}),
            h[top[u]].push_back(
                (line){fa[top[u]], i, 0, t + Get(x, fa[top[u]], c[i]), -c[i]});
      else
        h[top[u]].push_back((line){u, i, 0, T + Get(u, p, c[i]), c[i]}),
            h[top[u]].push_back(
                (line){fa[top[u]], i, 1, T + Get(fa[top[u]], p, c[i]), c[i]});
      u = fa[top[u]];
    }
    if (dep[u] < dep[v]) swap(u, v), flag ^= 1;
    if (flag)
      h[top[u]].push_back((line){u, i, 1, t + Get(x, u, c[i]), -c[i]}),
          h[top[u]].push_back((line){v, i, 0, T, -c[i]});
    else
      h[top[u]].push_back((line){v, i, 1, T, c[i]}),
          h[top[u]].push_back((line){u, i, 0, T + Get(u, v, c[i]), c[i]});
  }
  for (int i = 1; i <= n; i++)
    if (top[i] == i) work(i);
  if (fabs(ans - 1e10) < (double)1e-10)
    puts("-1");
  else
    printf("%.10lf\n", ans);
  return 0;
}
