#include <bits/stdc++.h>
using namespace std;
int A, B, rt, n, m, son[200005], h[200005], fa[200005], top[200005], s[200005];
double t, ans;
vector<int> a[200005];
vector<double> b[200005];
struct O {
  double l, r;
};
vector<O> T[200005];
struct P {
  double t;
  int f;
};
vector<P> w;
int lc[200005], rc[200005], ll[200005], rr[200005];
void up(int u) {
  ll[u] = lc[u] ? ll[lc[u]] : u;
  rr[u] = rc[u] ? rr[rc[u]] : u;
  s[u] = s[lc[u]] + s[rc[u]] + 1;
}
void split(int u, int k, int &l, int &r) {
  if (u == 0) {
    l = 0, r = 0;
    return;
  }
  if (a[m][u - 1] * t + b[m][u - 1] < a[m][k] * t + b[m][k] + 1e-8)
    l = u, split(rc[u], k, rc[u], r);
  else
    r = u, split(lc[u], k, l, lc[u]);
  up(u);
}
int SPLIT(int u) {
  if (rc[u] == 0) return lc[u];
  rc[u] = SPLIT(rc[u]);
  up(u);
  return u;
}
int merge(int l, int r) {
  if (l == 0 || r == 0) return l + r;
  if (1ll * (s[l] + s[r]) * rand() < 1ll * s[l] * RAND_MAX) {
    rc[l] = merge(rc[l], r);
    up(l);
    return l;
  } else {
    lc[r] = merge(l, lc[r]);
    up(r);
    return r;
  }
}
void dfs(int x, int y) {
  s[x] = 1;
  h[x] = h[y] + 1;
  fa[x] = y;
  for (int i = 0; i < (int)a[x].size(); ++i) {
    if (a[x][i] != y) {
      dfs(a[x][i], x);
      s[x] += s[a[x][i]];
      if (s[a[x][i]] > s[son[x]]) son[x] = a[x][i];
    }
  }
}
void Dfs(int x, int y) {
  if (son[x]) {
    top[son[x]] = top[x];
    Dfs(son[x], x);
  }
  for (int i = 0; i < (int)a[x].size(); ++i) {
    if (a[x][i] != y && a[x][i] != son[x]) {
      top[a[x][i]] = a[x][i];
      Dfs(a[x][i], x);
    }
  }
}
bool cmp(P u, P v) { return fabs(u.t - v.t) < 1e-8 ? u.f > v.f : u.t < v.t; }
void jud(int p, int q) {
  if (p == 0 || q == 0) return;
  --p;
  --q;
  if (a[m][p] == a[m][q]) {
    if (b[m][p] == b[m][q]) ans = min(ans, t);
    return;
  }
  double k = (b[m][q] - b[m][p]) / (a[m][p] - a[m][q]);
  if (k >= t - 1e-8 && k <= T[m][p].r + 1e-8 && k <= T[m][q].r + 1e-8)
    ans = min(ans, k);
}
int main() {
  ans = INT_MAX;
  cin >> n >> m;
  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    a[x].emplace_back(y);
    a[y].emplace_back(x);
  }
  dfs(1, 0);
  top[1] = 1;
  Dfs(1, 0);
  for (int i = 1; i <= n; ++i) a[i].clear();
  for (int i = 1; i <= m; ++i) {
    double l, r, tt, hh;
    int cc, u, v, p, q;
    cin >> tt >> cc >> u >> v;
    p = u;
    q = v;
    while (top[p] != top[q]) {
      if (h[top[p]] > h[top[q]])
        p = fa[top[p]];
      else
        q = fa[top[q]];
    }
    if (h[p] < h[q]) q = p;
    hh = 1.0 * (h[u] + h[v] - h[q] - h[q]) / cc + tt;
    p = u;
    q = v;
    while (top[p] != top[q]) {
      if (h[top[p]] > h[top[q]]) {
        a[top[p]].emplace_back(-cc);
        l = tt + 1.0 * (h[u] - h[p]) / cc,
        r = l + 1.0 * (h[p] - h[top[p]] + 1) / cc;
        b[top[p]].emplace_back(h[p] + l * cc);
        T[top[p]].emplace_back((O){l, r});
        p = fa[top[p]];
      } else {
        a[top[q]].emplace_back(cc);
        r = hh - 1.0 * (h[v] - h[q]) / cc,
        l = r - 1.0 * (h[q] - h[top[q]] + 1) / cc;
        b[top[q]].emplace_back(h[q] - r * cc);
        T[top[q]].emplace_back((O){l, r});
        q = fa[top[q]];
      }
    }
    a[top[p]].emplace_back(h[p] < h[q] ? cc : -cc);
    l = tt + 1.0 * (h[u] - h[p]) / cc, r = l + 1.0 * abs(h[q] - h[p]) / cc;
    b[top[p]].emplace_back(h[p] - l * (h[p] < h[q] ? cc : -cc));
    T[top[p]].emplace_back((O){l, r});
  }
  for (m = 1; m <= n; ++m) {
    for (int j = 0; j < (int)a[m].size(); ++j) {
      w.emplace_back((P){T[m][j].l, j + 1});
      w.emplace_back((P){T[m][j].r, -j - 1});
    }
    sort(w.begin(), w.end(), cmp);
    rt = 0;
    for (int j = 0; j < (int)w.size(); ++j) {
      t = w[j].t;
      if (ans <= t + 1e-8) break;
      if (w[j].f > 0) {
        lc[w[j].f] = rc[w[j].f] = 0;
        s[w[j].f] = 1;
        ll[w[j].f] = rr[w[j].f] = w[j].f;
        split(rt, w[j].f - 1, A, B);
        jud(rr[A], w[j].f);
        jud(ll[B], w[j].f);
        rt = merge(merge(A, w[j].f), B);
      } else {
        w[j].f *= -1;
        split(rt, w[j].f - 1, A, B);
        A = SPLIT(A);
        jud(rr[A], ll[B]);
        rt = merge(A, B);
      }
    }
    w.clear();
  }
  if (ans > 1000000)
    cout << "-1"
         << "\n";
  else
    cout << setprecision(20) << ans << "\n";
  return 0;
}
