#include <bits/stdc++.h>
namespace Long {
const int N = 101000, INF = 1000000007;
const double eps = 1e-7;
bool cmp(double a, double b) { return std::abs(a - b) < eps; }
double cur;
struct suit {
  int u, v, c;
  double t;
  suit(int u0 = 0, int v0 = 0, int c0 = 0, double t0 = 0) {
    u = u0, v = v0, c = c0 * (u < v ? 1 : -1), t = t0;
  }
  double begin() { return t; }
  double end() { return t + (v - u) * 1.0 / c; }
  bool operator<(const suit &A) const {
    assert(cur + eps > t && cur + eps > A.t);
    double x = u + (cur - t) * c, y = A.u + (cur - A.t) * A.c;
    return x < y;
  }
};
struct node {
  double t;
  int id, ty;
  node(double t0 = 0, int id0 = 0, int ty0 = 0) : t(t0), id(id0), ty(ty0) {}
  bool operator<(const node &A) const {
    return cmp(t, A.t) ? ty > A.ty : t < A.t;
  }
};
std::multiset<suit> S;
struct fucker {
  std::vector<std::set<suit>::iterator> ad;
  std::vector<suit> s;
  std::vector<node> t;
  inline void insert(suit A) { s.push_back(A); }
  double cross(suit A, suit B) {
    if (A.t > B.t) std::swap(A, B);
    if (A.end() + eps < B.begin()) return INF;
    double dt = B.begin() - A.begin(), pa = A.u + A.c * dt;
    double dx = pa - B.u, dc = A.c - B.c;
    if (cmp(dx, 0)) return B.begin();
    if (dx > eps && dc > -eps) return INF;
    if (dx < -eps && dc < eps) return INF;
    double ct = B.begin() - dx / dc;
    if (ct > A.end() + eps || ct > B.end() + eps) return INF;
    return ct;
  }
  double solve() {
    ad.resize(s.size());
    for (int i = 0; i < (int)s.size(); i++) {
      t.push_back(node(s[i].begin(), i, 1));
      t.push_back(node(s[i].end(), i, 0));
    }
    std::sort(t.begin(), t.end());
    S.clear();
    std::set<suit>::iterator it, pre, suc;
    double ret = INF;
    suit x;
    for (int i = 0; i < (int)t.size(); i++) {
      if (t[i].t > ret + eps) break;
      cur = t[i].t;
      if (t[i].ty) {
        x = s[t[i].id];
        it = S.insert(x);
        ad[t[i].id] = it;
        if (it != S.begin())
          --(pre = it), ret = std::min(ret, cross(*it, *pre));
        if (++(suc = it) != S.end()) ret = std::min(ret, cross(*it, *suc));
      } else {
        it = ad[t[i].id];
        if (it != S.begin() && ++(suc = it) != S.end())
          --(pre = it), ret = std::min(ret, cross(*pre, *suc));
        S.erase(it);
      }
    }
    return ret;
  }
} G[N];
int begin[N], next[N * 2], to[N * 2];
int n, m, e;
void add(int x, int y, bool k = 1) {
  to[++e] = y;
  next[e] = begin[x];
  begin[x] = e;
  if (k) add(y, x, 0);
}
int dep[N], top[N], fa[N];
int predfs(int p = 1, int h = 0) {
  fa[p] = h, top[p] = p, dep[p] = dep[h] + 1;
  int sizp = 1, sizq, maxsiz = 0, maxson = 0;
  for (int i = begin[p], q; i; i = next[i])
    if ((q = to[i]) != h) {
      sizp += (sizq = predfs(q, p));
      if (sizq > maxsiz) maxsiz = sizq, maxson = q;
    }
  if (maxson) top[maxson] = p;
  return sizp;
}
void redfs(int p = 1, int h = 0) {
  for (int i = begin[p], q; i; i = next[i])
    if ((q = to[i]) != h) {
      if (top[q] == p) top[q] = top[p];
      redfs(q, p);
    }
}
int getlca(int u, int v) {
  if (top[u] == top[v]) return dep[u] < dep[v] ? u : v;
  if (dep[top[u]] > dep[top[v]]) std::swap(u, v);
  return getlca(u, fa[top[v]]);
}
inline int id(int p) { return dep[p] - dep[top[p]] + 1; }
void work(int u, int v, int c, double tu, double tv) {
  if (top[u] == top[v])
    G[top[u]].insert(suit(id(u), id(v), c, tu));
  else if (dep[top[u]] <= dep[top[v]]) {
    double ct = id(v) * 1.0 / c;
    G[top[v]].insert(suit(0, id(v), c, tv - ct));
    work(u, fa[top[v]], c, tu, tv - ct);
  } else {
    double ct = id(u) * 1.0 / c;
    G[top[u]].insert(suit(id(u), 0, c, tu));
    work(fa[top[u]], v, c, tu + ct, tv);
  }
}
void initialize() {
  scanf("%d%d", &n, &m);
  for (int i = 1, u, v; i < n; i++) scanf("%d%d", &u, &v), add(u, v);
  predfs(), redfs();
  for (int i = 1, u, v, c, t, dis; i <= m; i++) {
    scanf("%d%d%d%d", &t, &c, &u, &v);
    dis = dep[u] + dep[v] - dep[getlca(u, v)] * 2;
    work(u, v, c, t, t + dis * 1.0 / c);
  }
}
void solve() {
  initialize();
  double ans = INF;
  for (int i = 1; i <= n; i++) ans = std::min(ans, G[i].solve());
  if (ans + eps >= INF)
    printf("-1\n");
  else
    printf("%.10lf\n", ans);
}
}  // namespace Long
int main() {
  Long::solve();
  return 0;
}
