#include <bits/stdc++.h>
using namespace std;
const double inf = 1e9;
const double eps = 1e-8;
double T;
struct line {
  int s, t;
  double v, x;
};
struct node {
  int s;
  vector<line> v;
} a[100002];
struct event {
  line l;
  double x;
  int op;
} q[100002 * 2];
bool operator<(line a, line b) {
  double ya = 1.0 * a.s + (T - a.x) * a.v;
  double yb = 1.0 * b.s + (T - b.x) * b.v;
  if (fabs(ya - yb) != 0) return ya < yb;
  if (fabs(a.v - b.v) != 0) return a.v < b.v;
  if (a.s != b.s) return a.s < b.s;
  return a.t < b.t;
}
int head[100002], ver[100002 * 2], nxt[100002 * 2], l;
int n, m, i, j, cnt, size[100002], son[100002], fa[100002], dep[100002],
    top[100002], id[100002];
multiset<line> s;
int read() {
  char c = getchar();
  int w = 0;
  while (c < '0' || c > '9') c = getchar();
  while (c <= '9' && c >= '0') {
    w = w * 10 + c - '0';
    c = getchar();
  }
  return w;
}
void insert(int x, int y) {
  l++;
  ver[l] = y;
  nxt[l] = head[x];
  head[x] = l;
}
void dfs1(int x, int pre) {
  dep[x] = dep[pre] + 1;
  size[x] = 1;
  fa[x] = pre;
  for (int i = head[x]; i; i = nxt[i]) {
    int y = ver[i];
    if (y != pre) {
      dfs1(y, x);
      size[x] += size[y];
      if (size[y] > size[son[x]]) son[x] = y;
    }
  }
}
void dfs2(int x, int t) {
  top[x] = t;
  if (top[x] == x) {
    cnt++;
    id[x] = cnt;
    if (x == 1)
      a[cnt].s = 1;
    else
      a[cnt].s = fa[x];
  } else
    id[x] = id[top[x]];
  if (son[x] != 0) dfs2(son[x], t);
  for (int i = head[x]; i; i = nxt[i]) {
    int y = ver[i];
    if (y != son[x] && y != fa[x]) dfs2(y, y);
  }
}
int LCA(int u, int v) {
  while (top[u] != top[v]) {
    if (dep[top[u]] < dep[top[v]]) swap(u, v);
    u = fa[top[u]];
  }
  if (dep[u] > dep[v]) swap(u, v);
  return u;
}
void add(int s, int t, int x, int v) {
  int dis = dep[s] + dep[t] - 2 * dep[LCA(s, t)];
  double et = 1.0 * x + 1.0 * dis / v, st = x;
  while (top[s] != top[t]) {
    if (dep[top[s]] > dep[top[t]]) {
      int c = id[s];
      line tmp;
      tmp.s = dep[s] - dep[a[c].s];
      tmp.t = 0;
      tmp.x = st;
      tmp.v = -v;
      a[c].v.push_back(tmp);
      st += 1.0 * (dep[s] - dep[a[c].s]) / v;
      s = fa[top[s]];
    } else {
      int c = id[t];
      line tmp;
      et -= 1.0 * (dep[t] - dep[a[c].s]) / v;
      tmp.s = 0;
      tmp.t = dep[t] - dep[a[c].s];
      tmp.x = et;
      tmp.v = v;
      a[c].v.push_back(tmp);
      t = fa[top[t]];
    }
  }
  if (dep[s] > dep[t]) {
    int c = id[s];
    line tmp;
    tmp.s = dep[s] - dep[a[c].s];
    tmp.t = dep[t] - dep[a[c].s];
    tmp.x = st;
    tmp.v = -v;
    a[c].v.push_back(tmp);
  } else {
    int c = id[t];
    line tmp;
    et -= 1.0 * (dep[t] - dep[s]) / v;
    tmp.s = dep[s] - dep[a[c].s];
    tmp.t = dep[t] - dep[a[c].s];
    tmp.x = et;
    tmp.v = v;
    a[c].v.push_back(tmp);
  }
}
double cal(line a, line b) {
  if (fabs(a.v - b.v) > eps) {
    double yb = 1.0 * b.s + (a.x - b.x) * b.v;
    double ans = a.x + (yb - a.s) / (a.v - b.v);
    if (ans > a.x - eps && ans > b.x - eps &&
        a.x + 1.0 * (a.t - a.s) / a.v + eps > ans &&
        b.x + 1.0 * (b.t - b.s) / b.v + eps > ans)
      return ans;
    return inf;
  } else {
    if (fabs(1.0 * (b.s - a.s) / a.v + a.x - b.x) == 0) return max(a.x, b.x);
    return inf;
  }
}
int my_comp(const event &a, const event &b) {
  if (fabs(a.x - b.x) > eps) return a.x < b.x;
  return a.op > b.op;
}
int main() {
  n = read();
  m = read();
  for (i = 1; i < n; i++) {
    int u = read(), v = read();
    insert(u, v);
    insert(v, u);
  }
  dfs1(1, 0);
  dfs2(1, 1);
  for (i = 1; i <= m; i++) {
    int x = read(), v = read(), s = read(), t = read();
    add(s, t, x, v);
  }
  double ans = inf;
  for (i = 1; i <= cnt; i++) {
    int num = 0;
    for (j = 0; j < a[i].v.size(); j++) {
      q[++num] = (event){a[i].v[j], a[i].v[j].x, 1};
      q[++num] = (event){
          a[i].v[j],
          a[i].v[j].x + 1.0 * (a[i].v[j].t - a[i].v[j].s) / a[i].v[j].v, -1};
    }
    sort(q + 1, q + num + 1, my_comp);
    s.clear();
    for (j = 1; j <= num; j++) {
      T = q[j].x;
      if (T > ans - eps) break;
      if (q[j].op == 1) {
        s.insert(q[j].l);
        multiset<line>::iterator it = s.lower_bound(q[j].l);
        multiset<line>::iterator nxt = it, pre = it;
        nxt++;
        if (nxt != s.end()) ans = min(ans, cal((*nxt), q[j].l));
        if (pre != s.begin()) {
          pre--;
          ans = min(ans, cal((*pre), q[j].l));
        }
      } else {
        s.erase(s.find(q[j].l));
        multiset<line>::iterator it = s.lower_bound(q[j].l);
        if (it != s.end() && it != s.begin()) {
          multiset<line>::iterator pre = it;
          pre--;
          ans = min(ans, cal((*it), (*pre)));
        }
      }
    }
  }
  if (ans >= inf)
    puts("-1");
  else
    printf("%.8lf\n", ans);
  return 0;
}
