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;
long long read() {
  long long x = 0, f = 0;
  char ch = getchar();
  while (!isdigit(ch)) f = ch == '-', ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  return f ? -x : x;
}
const int N = 100005;
int n, m;
vector<pair<int, int> > e[N];
long long dep[N];
void dfs(int x, long long d) {
  dep[x] = d;
  for (auto E : e[x]) dfs(E.first, d + E.second);
}
vector<pair<long long, long long> > v;
namespace lct {
int fa[N], son[N][2];
long long val[N], tag[N];
int isroot(int x) { return son[fa[x]][0] != x && son[fa[x]][1] != x; }
int wson(int x) { return son[fa[x]][1] == x; }
void rotate(int x) {
  int y = fa[x], z = fa[y], L = wson(x), R = L ^ 1;
  if (!isroot(y)) son[z][wson(y)] = x;
  fa[x] = z, fa[y] = x, fa[son[x][R]] = y;
  son[y][L] = son[x][R], son[x][R] = y;
}
void pushson(int x, long long v) {
  val[x] = max(val[x], v);
  tag[x] = max(tag[x], v);
}
void pushdown(int x) {
  if (tag[x]) {
    pushson(son[x][0], tag[x]);
    pushson(son[x][1], tag[x]);
    tag[x] = 0;
  }
}
void pushadd(int x) {
  if (!isroot(x)) pushadd(fa[x]);
  pushdown(x);
}
void splay(int x) {
  pushadd(x);
  for (int y = fa[x]; !isroot(x); rotate(x), y = fa[x])
    if (!isroot(y)) rotate(wson(x) == wson(y) ? y : x);
}
void access(int x, long long start_time) {
  int _x = x;
  int t = 0;
  while (x) {
    splay(x);
    if (x != _x) {
      v.push_back(make_pair(val[x] == 0 ? 1 : val[x] + dep[x] + 1,
                            start_time + dep[x]));
      son[x][1] = t;
    }
    t = x;
    x = fa[x];
  }
  x = _x;
  splay(x);
  if (son[x][0]) pushson(son[x][0], start_time);
}
}  // namespace lct
void gao(long long res) {
  printf("%lld ", res);
  if (res == -1) res = 1e18;
  int cnt = 0;
  for (auto i : v) cnt += i.second < res;
  printf("%d\n", cnt);
  exit(0);
}
int main() {
  n = read(), m = read();
  for (int i = (1); i <= (n - 1); i++) {
    int x = read(), y = read(), z = read();
    e[x].push_back(make_pair(y, z));
    lct::fa[y] = x, lct::son[x][1] = y;
  }
  dfs(1, 0);
  for (int i = (1); i <= (m); i++) {
    int s = read(), t = read();
    lct::access(s, t);
  }
  sort(v.begin(), v.end());
  priority_queue<long long, vector<long long>, greater<long long> > q;
  long long t = 1;
  int i = 0;
  for (auto p : v) {
    while (!q.empty() && t < p.first) {
      if (q.top() < t) {
        for (int j = (i + 1); j <= ((int)v.size() - 1); j++)
          if (v[j].second < q.top()) assert(0);
        gao(q.top());
      }
      q.pop();
      t++;
    }
    t = max(t, p.first);
    q.push(p.second);
    i++;
  }
  while (!q.empty()) {
    if (q.top() < t) gao(q.top());
    q.pop();
    t++;
  }
  gao(-1);
  return 0;
}
