That's right. I'm a Purdue student, and I shamelessly wrote a problem about trains.

There are n stations and m trains. The stations are connected by n-1 one-directional railroads that form a tree rooted at station 1. All railroads are pointed in the direction from the root station 1 to the leaves. A railroad connects a station u to a station v, and has a distance d, meaning it takes d time to travel from u to v. Each station with at least one outgoing railroad has a switch that determines the child station an incoming train will be directed toward. For example, it might look like this:

<image> Here, stations 1 and 3 have switches directed toward stations 2 and 4, respectively. 

Initially, no trains are at any station. Train i will enter station 1 at time t_i. Every unit of time, starting at time 1, the following two steps happen:

  1. You can switch at most one station to point to a different child station. A switch change takes effect before step 2. 
  2. For every train that is on a station u, it is directed toward the station v indicated by u's switch. So, if the railroad from u to v has distance d, the train will enter station v in d units of time from now. 



Every train has a destination station s_i. When it enters s_i, it will stop there permanently. If at some point the train is going in the wrong direction, so that it will never be able to reach s_i no matter where the switches point, it will immediately explode.

Find the latest possible time of the first explosion if you change switches optimally, or determine that you can direct every train to its destination so that no explosion occurs. Also, find the minimum number of times you need to change a switch to achieve this.

Input

The first line contains two integers n and m (1≤ n,m≤ 10^5) — the number of stations and trains, respectively.

The next n-1 lines describe the railroads. The i-th line contains three integers u,v,d (1≤ u,v≤ n, 1≤ d≤ 10^9), denoting a railroad from station u to station v with distance d. It is guaranteed that the railroads form a tree rooted at station 1. The switch of a station u is initially directed towards the last outgoing railroad from u that appears in the input.

The next m lines describe the trains. The i-th line contains two integers s_i,t_i (1≤ s_i≤ n, 1≤ t_1<t_2<⋅⋅⋅<t_m≤ 10^9) — the destination station and the time the i-th train enters station 1, respectively.

Output

Output two integers: the latest possible time of the first explosion (or -1 if it is possible to never have an explosion) and the minimum number of switch changes to achieve it.

Examples

Input


5 4
1 2 1
1 3 2
3 4 1
3 5 3
2 1
4 2
2 6
5 10


Output


-1 6


Input


5 4
1 2 1
1 3 2
3 4 1
3 5 3
5 1
4 2
4 3
2 4


Output


4 0


Input


11 6
1 2 1
1 3 2
3 4 1
3 5 2
5 6 1
5 7 2
7 8 1
7 9 2
9 10 1
9 11 1
2 1
8 3
6 5
10 7
4 9
2 11


Output


11 4

Note

For the first test, here's an example timeline: 

  * At time 1, train 1 enters station 1. We switch station 1 to point to station 2. Train 1 is directed to station 2. 
  * At time 2, train 2 enters station 1, and train 1 enters station 2, where it stops permanently. We switch station 1 to point to station 3. Train 2 is directed to station 3. 
  * At time 4, train 2 enters station 3. We switch station 3 to point to station 4. Train 2 is directed to station 4. 
  * At time 5, train 2 enters station 4, where it stops permanently. 
  * At time 6, train 3 enters station 1. We switch station 1 to point to station 2. Train 3 is directed to station 2. 
  * At time 7, train 3 enters station 2, where it stops permanently. We switch station 3 to point to station 5. 
  * At time 10, train 4 enters station 1. We switch station 1 to point to station 3. Train 4 is directed to station 3. 
  * At time 12, train 4 enters station 3. Train 4 is directed to station 5. 
  * At time 15, train 4 enters station 5, where it stops permanently. 



For the second test, we switch nothing. At time 4, train 2 is directed to station 5 and train 4 is directed to station 3. They both explode. It is impossible to prevent an explosion by time 4.

For the third test, denote a switch change by (u→ v,t) if we make station u point to station v at time t. One solution is to make these 4 switch changes: (1→ 2,1),(1→ 3,2),(7→ 8,5),(5→ 6,8). At time 11, trains 4,5, and 6 explode. It is impossible to prevent an explosion by time 11.
#include <bits/stdc++.h>
using namespace std;
const long long iinf = 1e9 + 10;
const long long inf = 1ll << 60;
const long long mod = 1e9 + 7;
void GG() {
  cout << "0\n";
  exit(0);
}
long long mpow(long long a, long long n, long long mo = mod) {
  long long re = 1;
  while (n > 0) {
    if (n & 1) re = re * a % mo;
    a = a * a % mo;
    n >>= 1;
  }
  return re;
}
long long inv(long long b, long long mo = mod) {
  if (b == 1) return b;
  return (mo - mo / b) * inv(mo % b, mo) % mo;
}
const long long maxn = 1e5 + 5;
struct edge {
  long long u, w, i;
};
vector<edge> g[maxn];
long long par[maxn], head[maxn], hv[maxn], sz[maxn], dep[maxn], wdep[maxn],
    last[maxn], which[maxn];
long long stp[maxn], enp[maxn], nof[maxn];
bool hasch[maxn];
priority_queue<pair<long long, long long>, vector<pair<long long, long long> >,
               greater<pair<long long, long long> > >
    pq[maxn];
long long lastedge[maxn], lasttime[maxn];
void dfs1(long long v, long long p) {
  sz[v] = 1;
  par[v] = p;
  long long bigsz = 0;
  for (edge e : g[v]) {
    if (e.u != p) {
      hasch[v] = 1;
      which[e.u] = e.i;
      par[e.u] = v;
      dep[e.u] = dep[v] + 1;
      wdep[e.u] = wdep[v] + e.w;
      lastedge[v] = e.i;
      dfs1(e.u, v);
      sz[v] += sz[e.u];
      if (sz[e.u] > bigsz) {
        hv[v] = e.u;
        bigsz = sz[e.u];
      }
    }
  }
  if (lastedge[v] == which[hv[v]]) {
    lastedge[v] = -1;
  }
  if (!hasch[v]) {
    lastedge[v] = -2;
  }
}
void dfs2(long long v, long long p) {
  nof[head[v]]++;
  if (lastedge[v] >= 0) {
    pq[head[v]].push({dep[v], v});
    ;
  }
  for (edge e : g[v]) {
    if (e.u == p) continue;
    if (hv[v] == e.u) {
      head[e.u] = head[v];
    } else {
      head[e.u] = e.u;
    }
    dfs2(e.u, v);
  }
}
vector<pair<long long, long long> > flist;
void add(long long v, long long t, long long pt) {
  flist.push_back({pt == 0 ? 0 : pt + wdep[v], t + wdep[v]});
}
long long second[maxn * 2];
void MO(long long p, long long v) {
  for (second[p += maxn] = v; p > 1; p >>= 1) {
    second[p >> 1] = max(second[p], second[p ^ 1]);
  }
}
long long QU(long long l, long long r) {
  long long re = 0;
  for (l += maxn, r += maxn; l < r; l >>= 1, r >>= 1) {
    if (l & 1) re = max(re, (__typeof__(re))(second[l++]));
    if (r & 1) re = max(re, (__typeof__(re))(second[--r]));
  }
  return re;
}
void go(long long v, long long t) {
  while (1) {
    ;
    long long H = head[v];
    while (!pq[H].empty() && pq[H].top().first < dep[v]) {
      long long u = pq[H].top().second;
      assert(lastedge[u] != -1);
      add(u, t, lasttime[u]);
      lastedge[u] = -1;
      pq[H].pop();
    }
    if (v != H) {
      MO(stp[H] + (dep[par[v]] - dep[H]), t);
      ;
    }
    v = H;
    if (v == 0) break;
    if (lastedge[par[v]] != which[v]) {
      long long pt = -1;
      if (lastedge[par[v]] == -1) {
        pq[head[par[v]]].push({dep[par[v]], par[v]});
        pt = QU(stp[head[par[v]]] + (dep[par[v]] - dep[head[par[v]]]),
                enp[head[par[v]]]);
        ;
      } else {
        pt = lasttime[par[v]];
      }
      lastedge[par[v]] = which[v];
      add(par[v], t, pt);
      ;
    }
    lasttime[par[v]] = t;
    v = par[v];
  }
}
struct EE {
  long long t, to;
  bool qu;
  bool operator<(const EE &b) const { return t != b.t ? t < b.t : qu > b.qu; }
};
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < n - 1; ++i) {
    long long a, b, w;
    cin >> a >> b >> w;
    --a;
    --b;
    g[a].push_back({b, w, i});
  }
  dfs1(0, -1);
  dfs2(0, -1);
  long long NOW = 0;
  for (long long i = 0; i < n; ++i) {
    if (head[i] == i) {
      stp[i] = NOW;
      enp[i] = NOW + nof[i];
      NOW += nof[i];
      ;
    }
  }
  for (long long i = 0; i < n; ++i)
    ;
  for (long long j = 0; j < m; ++j) {
    long long v, t;
    cin >> v >> t;
    --v;
    go(v, t);
  }
  long long prv = 0;
  vector<EE> ev;
  for (pair<long long, long long> &p : flist) {
    ev.push_back({p.first, p.second, 0});
    ev.push_back({p.second, -1, 1});
  }
  vector<long long> tyd;
  priority_queue<long long, vector<long long>, greater<long long> > fr;
  sort(ev.begin(), ev.end());
  long long ret = inf;
  for (EE e : ev) {
    for (long long j = 0; j < e.t - prv; ++j) {
      if (!fr.empty()) {
        tyd.push_back(fr.top());
        fr.pop();
      } else
        break;
    }
    if (e.qu) {
      if (!fr.empty() && fr.top() <= e.t) {
        assert(fr.top() == e.t);
        ret = e.t;
        break;
      }
    } else {
      fr.push(e.to);
    }
    prv = e.t;
  }
  long long nofsmol = 0;
  for (long long x : tyd) nofsmol += (x < ret);
  ;
  if (ret == inf) ret = -1;
  cout << ret << ' ' << nofsmol << '\n';
}
