#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const long double eps = 1e-10;
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, depth[N], size[N], hs[N], fa[N][21];
int ccnt, chtop[N], bel[N];
long double ans, T;
struct node {
  int k, b, l, r;
  node(int _k, int _b, int x, int y) {
    k = _k;
    b = _b;
    l = min(x, y);
    r = max(x, y);
  }
  void print() { printf("%d %d %d %d\n", k, b, l, r); }
};
bool operator<(node a, node b) {
  long double t1 = a.k * T + a.b, t2 = b.k * T + b.b;
  return t1 < t2;
  if (a.k != b.k) return a.k < b.k;
  if (a.b != b.b) return a.b < b.b;
  return (a.l != b.l) ? (a.l < b.l) : (a.r < b.r);
}
vector<int> e[N];
vector<node> b[N], a;
long double check(node a, node b) {
  int k = a.k - b.k, t = b.b - a.b;
  long double ret;
  if (!k) {
    if (t != 0) return 1e18;
    long double t1 = min((a.l - a.b) / (long double)a.k,
                         (a.r - a.b) / (long double)a.k),
                t2 = min((b.l - b.b) / (long double)b.k,
                         (b.r - b.b) / (long double)b.k);
    ret = max(t1, t2);
  } else {
    long double pos = (long long)a.k * t / (long double)k + a.b;
    ret = ((a.l <= pos + eps) && (a.r >= pos - eps) && (b.l <= pos + eps) &&
           (b.r >= pos - eps))
              ? (t / (long double)k)
              : 1e18;
  }
  return ret;
}
void build(int x, int fath) {
  size[x] = 1;
  hs[x] = 0;
  depth[x] = depth[fath] + 1;
  fa[x][0] = fath;
  for (int i = 1; i < 20; i++) fa[x][i] = fa[fa[x][i - 1]][i - 1];
  for (auto y : e[x])
    if (y != fath) {
      build(y, x);
      size[x] += size[y];
      if (size[y] > size[hs[x]]) hs[x] = y;
    }
}
void build2(int x, int fath) {
  bel[x] = ccnt;
  if (hs[x]) build2(hs[x], x);
  for (auto y : e[x])
    if ((y != fath) && (y != hs[x])) {
      chtop[++ccnt] = y;
      build2(y, 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[x][i]] >= depth[y]) x = fa[x][i];
  if (x == y) return x;
  for (int i = 19; i >= 0; i--)
    if (fa[x][i] != fa[y][i]) x = fa[x][i], y = fa[y][i];
  return fa[x][0];
}
void work(int x, int y, int k, int b1, int b2) {
  while (bel[x] != bel[y]) {
    if (depth[chtop[bel[x]]] < depth[chtop[bel[y]]]) {
      swap(x, y);
      swap(b1, b2);
      k = -k;
    }
    b[bel[x]].push_back(node(k, b1, depth[chtop[bel[x]]] - 1, depth[x]));
    x = fa[chtop[bel[x]]][0];
  }
  if (depth[x] < depth[y]) {
    swap(x, y);
    swap(b1, b2);
    k = -k;
  }
  b[bel[x]].push_back(node(k, b1, depth[x], depth[y]));
}
vector<pair<long double, int> > g;
multiset<node> h;
long double calc() {
  long double ans = 1e18;
  g.clear();
  for (int i = 0; i < (int)a.size(); i++) {
    long double tl = (long double)(a[i].l - a[i].b) / a[i].k,
                tr = (long double)(a[i].r - a[i].b) / a[i].k;
    if (tl > tr) swap(tl, tr);
    g.push_back(make_pair(tl, i + 1));
    g.push_back(make_pair(tr + eps, -i - 1));
  }
  sort(g.begin(), g.end());
  h.clear();
  int i;
  multiset<node>::iterator it, itl;
  for (auto t : g) {
    T = t.first;
    i = abs(t.second) - 1;
    if (T >= ans - eps) return ans;
    if (t.second > 0) {
      it = h.lower_bound(a[i]);
      if (it != h.end()) ans = min(ans, check(*it, a[i]));
      if (it != h.begin()) {
        it--;
        ans = min(ans, check(*it, a[i]));
      }
      h.insert(a[i]);
    } else {
      it = h.lower_bound(a[i]);
      if (it == h.end()) {
        a[i].print();
        printf("%.12Lf %.12Lf\n", T, ans);
        for (auto t : h) t.print();
        it--;
      }
      h.erase(it);
      itl = h.lower_bound(a[i]);
      if ((itl != h.end()) && (itl != h.begin())) {
        it = itl;
        itl--;
        ans = min(ans, check(*it, *itl));
      }
    }
  }
  return ans;
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i < n; i++) {
    int u = read(), v = read();
    e[u].push_back(v);
    e[v].push_back(u);
  }
  build(1, 0);
  chtop[++ccnt] = 1;
  build2(1, 0);
  while (m--) {
    int t = read(), k = read(), x = read(), y = read(), z = lca(x, y);
    if (k == 0) k = 1;
    int b = depth[x] + k * t;
    work(x, y, -k, b, depth[z] - (b - depth[z]));
  }
  ans = 1e18;
  for (int i = 1; i <= ccnt; i++) {
    swap(a, b[i]);
    ans = min(ans, calc());
  }
  if (ans < 1e16)
    printf("%.8Lf\n", ans);
  else
    puts("-1");
  return 0;
}
