Problem: Tony Stark is playing a game with his suits (they have auto-pilot now). He lives in Malibu. Malibu has n junctions numbered from 1 to n, connected with n - 1 roads. One can get from a junction to any other junction using these roads (graph of Malibu forms a tree).

Tony has m suits. There's a special plan for each suit. The i-th suit will appear at the moment of time ti in the junction vi, and will move to junction ui using the shortest path between vi and ui with the speed ci roads per second (passing a junctions takes no time), and vanishing immediately when arriving at ui (if it reaches ui in time q, it's available there at moment q, but not in further moments). Also, suits move continuously (for example if vi ≠ ui, at time <image> it's in the middle of a road. Please note that if vi = ui it means the suit will be at junction number vi only at moment ti and then it vanishes. 

An explosion happens if at any moment of time two suits share the same exact location (it may be in a junction or somewhere on a road; while appearing, vanishing or moving).

Your task is to tell Tony the moment of the the first explosion (if there will be any).

Input

The first line of the input contains two integers n and m (1 ≤ n, m ≤ 100 000) — the number of junctions and the number of suits respectively.

The next n - 1 lines contain the roads descriptions. Each line contains two integers ai and bi — endpoints of the i-th road (1 ≤ ai, bi ≤ n, ai ≠ bi).

The next m lines contain the suit descriptions. The i-th of them contains four integers ti, ci, vi and ui (0 ≤ ti ≤ 10 000, 1 ≤ ci ≤ 10 000, 1 ≤ vi, ui ≤ n), meaning the i-th suit will appear at moment of time ti at the junction vi and will move to the junction ui with a speed ci roads per second.

Output

If there would be no explosions at all, print -1 in the first and only line of output.

Otherwise print the moment of the first explosion.

Your answer will be considered correct if its relative or absolute error doesn't exceed 10 - 6.

Examples

Input

6 4
2 5
6 5
3 6
4 6
4 1
27 6 1 3
9 5 1 6
27 4 3 4
11 29 2 6


Output

27.3


Input

6 4
3 1
4 5
6 4
6 1
2 6
16 4 4 5
13 20 6 2
3 16 4 5
28 5 3 5


Output

-1

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 100000;
const int MAXM = MAXN - 1;
const int MAXS = 100000;
const int MAXLOGN = 16;
const int MAXL = MAXS * (2 * MAXLOGN + 1);
const int MAXE = 2 * MAXL;
typedef struct T {
  long long num;
  int den;
  T() { num = 0, den = 1; }
  T(long long n, long long d) {
    long long g = gcd(n, d);
    num = n / g, den = d / g;
  }
  T(long long a, long long b, long long c) {
    long long n = a * c + b, d = c, g = gcd(n, d);
    num = n / g, den = d / g;
  }
  double val() { return 1.0 * num / den; }
} T;
bool operator==(const T &a, const T &b) {
  return a.num == b.num && a.den == b.den;
}
T operator-(const T &a, const T &b) {
  return T(a.num * b.den - b.num * a.den, a.den * b.den);
}
T operator/(const T &a, const T &b) { return T(a.num * b.den, a.den * b.num); }
T operator*(const T &a, const long long &b) { return T(a.num * b, a.den); }
T operator+(const long long &a, const T &b) {
  return T(a * b.den + b.num, b.den);
}
bool operator<(const T &a, const T &b) { return a.num * b.den < b.num * a.den; }
int n, ns;
int ghead[MAXN], gnxt[2 * MAXM], gto[2 * MAXM];
int q[MAXN], qhead, qtail;
int d[MAXN], par[MAXN], sz[MAXN], heavy[MAXN], hroot[MAXN], hidx[MAXN], nhidx;
int lca(int a, int b) {
  while (hroot[a] != hroot[b]) {
    if (d[hroot[a]] > d[hroot[b]]) swap(a, b);
    b = par[hroot[b]];
  }
  if (d[a] > d[b]) swap(a, b);
  return a;
}
typedef struct L {
  int x1;
  T y1;
  int x2;
  T y2;
  T getx(T y) const {
    if (y1 == y2) return T(x1, 1);
    return x1 + (y - y1) / (y2 - y1) * (x2 - x1);
  }
} L;
L l[MAXL];
int nl;
T scanliney;
typedef struct scanlinecmp {
  bool operator()(const int &aa, const int &bb) {
    T ax = l[aa].getx(scanliney), bx = l[bb].getx(scanliney);
    return ax < bx;
  }
} scanlinecmp;
typedef struct ecmp {
  bool operator()(const int &aa, const int &bb) {
    int aidx = aa / 2, atype = aa % 2 == 0 ? +1 : -1;
    int bidx = bb / 2, btype = bb % 2 == 0 ? +1 : -1;
    T ay = atype == +1 ? l[aidx].y1 : l[aidx].y2;
    T by = btype == +1 ? l[bidx].y1 : l[bidx].y2;
    if (!(ay == by)) return ay < by;
    if (atype != btype) return atype > btype;
    return aidx < bidx;
  }
} ecmp;
int e[MAXE];
int ne;
void addseg(int x1, T y1, int x2, T y2) {
  if (nl > MAXL) {
    printf("too many segs\n");
    exit(0);
  }
  if (y2 < y1) swap(x1, x2), swap(y1, y2);
  l[nl].x1 = x1;
  l[nl].y1 = y1;
  l[nl].x2 = x2;
  l[nl].y2 = y2;
  ++nl;
}
typedef struct P {
  double x, y;
  P(double x, double y) : x(x), y(y) {}
} P;
P operator-(const P &a, const P &b) { return P(a.x - b.x, a.y - b.y); }
double operator^(const P &a, const P &b) { return a.x * b.y - a.y * b.x; }
double intersect(const P &a, const P &b, const P &c, const P &d) {
  double num = (d - c) ^ (c - a);
  double den = (d - c) ^ (b - a);
  double t = num / den;
  return a.y + t * (b.y - a.y);
}
void updateintersection(double &yfst, T &cy, int aa, int bb) {
  L &a = l[aa];
  L &b = l[bb];
  T topy = a.y2 < b.y2 ? a.y2 : b.y2;
  T atopx = a.getx(topy), btopx = b.getx(topy);
  if (atopx < btopx) return;
  double ycur = intersect(P(a.x1, a.y1.val()), P(a.x2, a.y2.val()),
                          P(b.x1, b.y1.val()), P(b.x2, b.y2.val()));
  if (ycur < yfst) yfst = ycur;
}
void solve() {
  scanlinecmp cmp;
  set<int, scanlinecmp> scanline(cmp);
  ne = 0;
  for (int i = (0); i < (nl); ++i) {
    e[ne++] = 2 * i + 0;
    e[ne++] = 2 * i + 1;
  }
  sort(e, e + ne, ecmp());
  double yfst = 1e200;
  for (int i = (0); i < (ne); ++i) {
    int eidx = e[i] / 2, etype = e[i] % 2 == 0 ? +1 : -1;
    T y = etype == +1 ? l[eidx].y1 : l[eidx].y2;
    scanliney = y;
    if (y.val() + 1e-9 > yfst) {
      printf("%.9lf\n", yfst);
      return;
    }
    if (etype == +1) {
      set<int, scanlinecmp>::iterator at = scanline.lower_bound(eidx);
      if (at != scanline.end() && l[*at].getx(y) == T(l[eidx].x1, 1)) {
        printf("%.9lf\n", 1.0 * y.num / y.den);
        return;
      }
      if (at != scanline.end()) updateintersection(yfst, y, eidx, *at);
      if (at != scanline.begin()) {
        set<int, scanlinecmp>::iterator prv = at;
        --prv;
        updateintersection(yfst, y, *prv, eidx);
      }
      scanline.insert(eidx);
    }
    if (etype == -1) {
      set<int, scanlinecmp>::iterator at = scanline.lower_bound(eidx);
      assert(at != scanline.end() && *at == eidx);
      set<int, scanlinecmp>::iterator nxt = at;
      ++nxt;
      if (at != scanline.begin() && nxt != scanline.end()) {
        set<int, scanlinecmp>::iterator prv = at;
        --prv;
        updateintersection(yfst, y, *prv, *nxt);
      }
      scanline.erase(at);
    }
  }
  printf("-1\n");
}
void run() {
  scanf("%d%d", &n, &ns);
  for (int i = (0); i < (n); ++i) ghead[i] = -1;
  for (int i = (0); i < (n - 1); ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a, --b;
    gnxt[2 * i + 0] = ghead[a];
    ghead[a] = 2 * i + 0;
    gto[2 * i + 0] = b;
    gnxt[2 * i + 1] = ghead[b];
    ghead[b] = 2 * i + 1;
    gto[2 * i + 1] = a;
  }
  qhead = qtail = 0;
  memset(par, -1, sizeof(par));
  d[0] = 0;
  q[qhead++] = 0;
  while (qtail < qhead) {
    int at = q[qtail++];
    for (int x = ghead[at]; x != -1; x = gnxt[x]) {
      int to = gto[x];
      if (to == par[at]) continue;
      par[to] = at;
      d[to] = d[at] + 1;
      q[qhead++] = to;
    }
  }
  for (int i = (0); i < (n); ++i) sz[i] = 1;
  for (int i = n - 1; i >= 0; --i) sz[par[q[i]]] += sz[q[i]];
  for (int i = (0); i < (n); ++i) heavy[i] = -1;
  for (int i = (0); i < (n); ++i)
    if (par[i] != -1 && (heavy[par[i]] == -1 || sz[i] > sz[heavy[par[i]]]))
      heavy[par[i]] = i;
  nhidx = 0;
  for (int i = (0); i < (n); ++i) hidx[i] = -1;
  for (int i = (0); i < (n); ++i)
    if (hidx[q[i]] == -1)
      for (int at = q[i]; at != -1; at = heavy[at])
        hidx[at] = nhidx++, hroot[at] = q[i];
  nl = 0;
  for (int i = (0); i < (ns); ++i) {
    int t, v, a, b;
    scanf("%d%d%d%d", &t, &v, &a, &b);
    --a, --b;
    int c = lca(a, b), dst = d[a] + d[b] - 2 * d[c];
    int aa = a;
    while (hroot[aa] != hroot[c]) {
      addseg(hidx[hroot[aa]], T(t, d[a] - d[hroot[aa]], v), hidx[aa],
             T(t, d[a] - d[aa], v));
      aa = hroot[aa];
      addseg(n + 2 * aa, T(t, d[a] - d[aa], v), n + 2 * aa + 1,
             T(t, d[a] - d[par[aa]], v));
      aa = par[aa];
    }
    int bb = b;
    while (hroot[bb] != hroot[c]) {
      addseg(hidx[hroot[bb]], T(t, dst - d[b] + d[hroot[bb]], v), hidx[bb],
             T(t, dst - d[b] + d[bb], v));
      bb = hroot[bb];
      addseg(n + 2 * bb, T(t, dst - d[b] + d[bb], v), n + 2 * bb + 1,
             T(t, dst - d[b] + d[par[bb]], v));
      bb = par[bb];
    }
    addseg(hidx[aa], T(t, d[a] - d[aa], v), hidx[bb],
           T(t, dst - d[b] + d[bb], v));
  }
  solve();
}
int main() {
  run();
  return 0;
}