#include <bits/stdc++.h>
using namespace std;
int A[100001], B[3300033], D[3300033], O[100001], P[100001], Q, a[100001],
    b[200002], c[200002], d[100001], e[3300033], f[100001], g[100001],
    h[100001], l[3300033][2], m, n, r, s[3300033], t;
double C[3300033], E[3300033], F[3300033], x;
inline double _k(int u, int v) {
  if (D[u] == D[v])
    return C[v] - C[u] < 1e-10 ? max(E[u], E[v]) : x;
  else
    return max(E[u], E[v]) <= (C[v] - C[u]) / (D[u] - D[v]) + 1e-10 &&
                   (C[v] - C[u]) / (D[u] - D[v]) <= min(F[u], F[v]) + 1e-10
               ? (C[v] - C[u]) / (D[u] - D[v])
               : x;
}
inline void _j(int u) { s[u] = s[l[u][0]] + s[l[u][1]] + 1; }
inline int _i(int u, int v) {
  while (true)
    if (v == s[l[u][0]] + 1)
      return u;
    else if (v <= s[l[u][0]])
      u = l[u][0];
    else
      v -= s[l[u][0]] + 1, u = l[u][1];
}
inline void _h(int& u, int v) {
  int w = l[u][v];
  l[u][v] = l[w][v ^ 1], _j(l[w][v ^ 1] = u), u = w;
}
int _g(int& u, int v) {
  if (u != v)
    return s[u]--, C[u] + D[u] * F[v] < C[v] + D[v] * F[v]
                       ? s[l[u][0]] + 1 + _g(l[u][1], v)
                       : _g(l[u][0], v);
  else if (!l[u][0] || !l[u][1])
    return l[u][1] ? u = l[u][1], 0 : s[u = l[u][0]];
  else if (e[l[u][0]] < e[l[u][1]])
    _h(u, 0), s[u] = s[l[u][0]] + s[l[u][1]], _g(l[u][0], v);
  else
    return _h(u, 1), s[u] = s[l[u][0]] + s[l[u][1]],
                     s[l[u][0]] + 1 + _g(l[u][1], v);
}
int _f(int& u, int v) {
  int S;
  if (!u)
    e[u = v] = rand(), S = 1;
  else if (C[v] + D[v] * E[v] < C[u] + D[u] * E[v])
    S = _f(l[u][0], v), e[l[u][0]] < e[u] ? _h(u, 0), 0 : 0;
  else
    S = s[l[u][0]] + 1 + _f(l[u][1], v), e[l[u][1]] < e[u] ? _h(u, 1), 0 : 0;
  return _j(u), S;
}
inline bool _e(int u, int v) { return F[u] < F[v]; }
inline bool _d(int u, int v) { return E[u] < E[v]; }
inline void _c(int u, int v, int w, double y) {
  int i = u, j = v;
  double z = d[u] + d[v];
  while (h[i] != h[j]) d[h[i]] < d[h[j]] ? j = f[h[j]] : i = f[h[i]];
  z -= d[i] < d[j] ? d[j = i] << 1 : d[i = j] << 1, z = z / w + y;
  while (h[u] != h[i])
    B[++t] = A[h[u]], C[A[h[u]] = t] = d[u] + w * y, D[t] = -w, E[t] = y,
    F[t] = y += (double)(d[u] - d[f[h[u]]]) / w, u = f[h[u]];
  while (h[v] != h[j])
    B[++t] = A[h[v]], C[A[h[v]] = t] = d[v] - w * z, D[t] = w, F[t] = z,
    E[t] = z -= (double)(d[v] - d[f[h[v]]]) / w, v = f[h[v]];
  if (d[u] < d[v])
    B[++t] = A[h[v]], C[A[h[v]] = t] = d[v] - w * z, D[t] = w, F[t] = z,
    E[t] = z -= (double)(d[v] - d[j]) / w;
  else
    B[++t] = A[h[u]], C[A[h[u]] = t] = d[u] + w * y, D[t] = -w, E[t] = y,
    F[t] = y += (double)(d[u] - d[i]) / w;
}
void _b(int u) {
  if (s[u] = 0, g[u]) h[g[u]] = h[u], _b(g[u]);
  for (int& i = a[u]; i; i = b[i])
    if (c[i] != f[u] && c[i] != g[u]) _b(h[c[i]] = c[i]);
}
void _a(int u) {
  s[u] = 1, d[u] = d[f[u]] + 1;
  for (int i = a[u]; i; i = b[i])
    if (c[i] != f[u])
      f[c[i]] = u, _a(c[i]), s[u] += s[c[i]],
      g[u] = s[g[u]] < s[c[i]] ? c[i] : g[u];
}
int main() {
  scanf("%d%d", &n, &m), srand(time(0)), x = 1e9 + 7;
  for (int i = 1, u, v; i < n; i++)
    scanf("%d%d", &u, &v), b[++t] = a[u], c[a[u] = t] = v, b[++t] = a[v],
                           c[a[v] = t] = u;
  _a(1), _b(h[1] = 1), t = 0;
  for (int u, v, w, y; m; m--)
    scanf("%d%d%d%d", &y, &w, &u, &v), _c(u, v, w, y);
  for (int i = 1; i <= n; i++)
    if (A[i]) {
      for (Q = r = 0; A[i];) O[++Q] = A[i], P[Q] = A[i], A[i] = B[A[i]];
      sort(O + 1, O + Q + 1, _d), sort(P + 1, P + Q + 1, _e);
      for (int j = 1, k = 1, u, v = 0;;)
        if (j <= Q && (Q < k || E[O[j]] - F[P[k]] < 1e-10) && E[O[j]] < x)
          u = _f(r, O[j]), u != 1 ? x = min(x, _k(_i(r, u - 1), O[j])) : 0.0,
          u != ++v ? x = min(x, _k(O[j], _i(r, u + 1))) : 0.0, j++;
        else if (k <= Q && (Q < j || 1e-10 < E[O[j]] - F[P[k]]) && F[P[k]] < x)
          u = _g(r, P[k]),
          u != --v&& u ? x = min(x, _k(_i(r, u), _i(r, u + 1))) : 0.0, k++;
        else
          break;
    }
  return 0 & (1e9 < x ? puts("-1") : printf("%.30lf\n", x));
}
