#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const int N = 100005;
int read() {
  int f = 1, g = 0;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) g = g * 10 + ch - '0';
  return f * g;
}
int n, m, siz, fir[N];
double ans;
struct edge {
  int u, v, nex;
} e[N * 2];
void add(int u, int v) {
  e[++siz] = (edge){u, v, fir[u]};
  fir[u] = siz;
}
int size[N], depth[N], hs[N], fa[N][20], bel[N];
int ccnt, chtop[N];
void build(int x, int fath) {
  fa[x][0] = fath;
  size[x] = 1;
  depth[x] = depth[fath] + 1;
  hs[x] = 0;
  for (int i = 1; i < 20; i++) fa[x][i] = fa[fa[x][i - 1]][i - 1];
  for (int i = fir[x]; i; i = e[i].nex)
    if (e[i].v != fath) {
      build(e[i].v, x);
      size[x] += size[e[i].v];
      if (size[e[i].v] > size[hs[x]]) hs[x] = e[i].v;
    }
}
void build2(int x, int fath) {
  bel[x] = ccnt;
  if (hs[x])
    build2(hs[x], x);
  else
    return;
  for (int i = fir[x]; i; i = e[i].nex)
    if ((e[i].v != fath) && (e[i].v != hs[x])) {
      chtop[++ccnt] = e[i].v;
      build2(e[i].v, x);
    }
}
int lca(int x, int y) {
  if (depth[x] > depth[y]) swap(x, y);
  for (int i = 19; i >= 0; i--)
    if (depth[fa[y][i]] >= depth[x]) y = fa[y][i];
  if (x == y) return x;
  for (int i = 19; i >= 0; i--)
    if (fa[y][i] != fa[x][i]) {
      x = fa[x][i];
      y = fa[y][i];
    }
  return fa[x][0];
}
double T;
struct node {
  int l, r, t, st, v;
};
vector<node> a;
double posi(node a) { return a.v * (T - a.t) + a.st; }
double appear_time(node a) {
  double t1 = 1.0 * (a.l - a.st) / a.v, t2 = 1.0 * (a.r - a.st) / a.v;
  return min(t1, t2) + a.t;
}
double vanish_time(node a) {
  double t1 = 1.0 * (a.l - a.st) / a.v, t2 = 1.0 * (a.r - a.st) / a.v;
  return max(t1, t2) + a.t;
}
double meet_time(node a, node b) {
  int k1 = a.v, k2 = b.v;
  long long b1 = a.st - (long long)a.t * a.v, b2 = b.st - (long long)b.t * b.v;
  double t, p1, p2;
  if (k1 == k2) {
    if (b1 == b2)
      t = max(appear_time(a), appear_time(b));
    else
      return 1e18;
  } else
    t = 1.0 * (b2 - b1) / (k1 - k2);
  p1 = t * k1 + b1, p2 = t * k2 + b2;
  if ((p1 + eps < a.l) || (p1 - eps > a.r) || (p2 + eps < b.l) ||
      (p2 - eps > b.r))
    return 1e18;
  return t;
}
struct heap_node {
  double tim;
  int x, typ;
};
bool operator<(heap_node a, heap_node b) { return a.tim > b.tim; }
struct set_node {
  int x;
};
bool operator<(set_node x, set_node y) {
  double t = posi(a[x.x]) - posi(a[y.x]);
  return (abs(t) >= eps) ? (t < 0) : (x.x < y.x);
}
struct seq {
  priority_queue<heap_node> f;
  set<set_node> h;
  double fans;
  void push(node x) {
    a.push_back(x);
    int i = a.size() - 1;
    double t1 = appear_time(x), t2 = vanish_time(x);
    f.push((heap_node){t1, i, 0});
    f.push((heap_node){t2 + eps, i, 2});
  }
  double solve() {
    T = 0;
    fans = 1e18;
    while (!f.empty()) {
      heap_node cur = f.top();
      f.pop();
      node aa = a[cur.x];
      if (cur.tim > fans) break;
      if (cur.typ == 0) {
        T = cur.tim;
        set_node t;
        t.x = cur.x;
        set<set_node>::iterator it = h.lower_bound(t);
        if (it != h.end()) {
          fans = min(fans, meet_time(a[t.x], a[(*it).x]) - eps);
        }
        if (it != h.begin()) {
          it--;
          fans = min(fans, meet_time(a[t.x], a[(*it).x]) - eps);
        }
        h.insert(t);
      } else {
        T = cur.tim;
        set_node t;
        t.x = cur.x;
        h.erase(t);
        set<set_node>::iterator it = h.lower_bound(t), itl;
        if ((it != h.begin()) && (it != h.end())) {
          itl = it;
          itl--;
          fans = min(fans, meet_time(a[(*itl).x], a[(*it).x]) - eps);
        }
      }
    }
    return fans;
  }
} f[N];
int fl;
void work(int u, int v, int t, int s, int c) {
  while (bel[u] != bel[v]) {
    int z = fa[chtop[bel[u]]][0];
    f[bel[u]].push((node){depth[z], depth[u], t, s, c});
    u = z;
  }
  if (u != v) {
    fl = 1;
    f[bel[u]].push((node){depth[v], depth[u], t, s, c});
  }
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i < n; i++) {
    int u = read(), v = read();
    add(u, v);
    add(v, u);
  }
  build(1, 0);
  chtop[++ccnt] = 1;
  build2(1, 0);
  while (m--) {
    int t = read(), c = read(), u = read(), v = read(), z = lca(u, v);
    fl = 0;
    work(u, z, t, depth[u], -c);
    work(v, z, t, depth[z] - (depth[u] - depth[z]), c);
    if (!fl) {
      f[bel[z]].push((node){depth[z], depth[z], t, depth[u], -c});
    }
  }
  ans = 1e18;
  for (int i = 1; i <= ccnt; i++) {
    ans = min(ans, f[i].solve());
  }
  if (ans > 1e10)
    puts("-1");
  else
    printf("%.9lf\n", ans);
  return 0;
}
