Rick is in love with Unity. But Mr. Meeseeks also love Unity, so Rick and Mr. Meeseeks are "love rivals". 

Unity loves rap, so it decided that they have to compete in a rap game (battle) in order to choose the best. Rick is too nerds, so instead he's gonna make his verse with running his original algorithm on lyrics "Rap God" song.

<image>

His algorithm is a little bit complicated. He's made a tree with n vertices numbered from 1 to n and there's a lowercase english letter written on each edge. He denotes str(a, b) to be the string made by writing characters on edges on the shortest path from a to b one by one (a string of length equal to distance of a to b). Note that str(a, b) is reverse of str(b, a) and str(a, a) is empty.

In order to make the best verse he can, he needs to answer some queries, but he's not a computer scientist and is not able to answer those queries, so he asked you to help him. Each query is characterized by two vertices x and y (x ≠ y). Answer to this query is the number of vertices like z such that z ≠ x, z ≠ y and str(x, y) is lexicographically larger than str(x, z).

String x = x1x2...x|x| is lexicographically larger than string y = y1y2...y|y|, if either |x| > |y| and x1 = y1, x2 = y2, ..., x|y| = y|y|, or exists such number r (r < |x|, r < |y|), that x1 = y1, x2 = y2, ..., xr = yr and xr + 1 > yr + 1. Characters are compared like their ASCII codes (or alphabetic order).

Help Rick get the girl (or whatever gender Unity has).

Input

The first line of input contain two integers n and q (2 ≤ n ≤ 20000, 1 ≤ q ≤ 20000) — number of vertices in tree and number of queries respectively.

The next n - 1 lines contain the edges. Each line contains two integers v and u (endpoints of the edge) followed by an English lowercase letter c (1 ≤ v, u ≤ n, v ≠ u).

The next q line contain the queries. Each line contains two integers x and y (1 ≤ x, y ≤ n, x ≠ y).

Output

Print the answer for each query in one line.

Examples

Input

4 3
4 1 t
3 2 p
1 2 s
3 2
1 3
2 1


Output

0
1
1


Input

8 4
4 6 p
3 7 o
7 8 p
4 5 d
1 3 o
4 3 p
3 2 e
8 6
3 7
8 1
4 3


Output

6
1
3
1

Note

Here's the tree of first sample testcase:

<image>

Here's the tree of second sample testcase:

<image>

In this test:

  * str(8, 1) = poo
  * str(8, 2) = poe
  * str(8, 3) = po
  * str(8, 4) = pop
  * str(8, 5) = popd
  * str(8, 6) = popp
  * str(8, 7) = p



So, for the first query, <image> and for the third query <image> is the answer.
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
const int N = 40100;
int T, p[N], c[N], dep[N], ch[N], vis[N], st[N], q, ret[N], cp[N];
int n, u, v;
char s[10];
vector<pair<int, int> > e[N], Q[N];
void dfs(int u, int f) {
  for (auto v : e[u])
    if (v.first != f) {
      dfs(v.first, u);
      p[v.first] = u;
      c[v.first] = v.second;
    }
}
int gao(int u, int v) {
  T++;
  int r = v, tot = 0;
  dep[v] = n;
  int ret = -1;
  while (r != u) {
    ch[dep[r]] = c[r];
    vis[r] = T;
    cp[r] = 1;
    dep[p[r]] = dep[r] - 1;
    r = p[r];
    ret++;
  }
  vis[u] = T;
  cp[u] = 1;
  for (int j = 1; j < n + 1; j++)
    if (vis[j] != T) {
      int top = 0, r = j;
      while (vis[r] != T) st[top++] = r, r = p[r];
      for (int i = top - 1; i >= 0; i--) {
        int r = st[i];
        dep[r] = dep[p[r]] + 1;
        vis[r] = T;
        if (cp[p[r]] != 1)
          cp[r] = cp[p[r]];
        else if (ch[dep[r]] > c[r])
          cp[r] = 0;
        else if (ch[dep[r]] == c[r])
          cp[r] = 1;
        else
          cp[r] = 2;
        ret += (cp[r] == 0) || (cp[r] == 1 && dep[r] < dep[v]);
      }
    }
  return ret;
}
void solve(int u, int f) {
  for (auto v : Q[u]) ret[v.second] = gao(u, v.first);
  int pr = c[u];
  for (auto v : e[u])
    if (v.first != f) {
      p[u] = v.first;
      c[u] = v.second;
      solve(v.first, u);
    }
  c[u] = pr;
  p[u] = f;
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i < n; i++) {
    scanf("%d%d%s", &u, &v, s);
    e[u].push_back(make_pair(v, s[0]));
    e[v].push_back(make_pair(u, s[0]));
  }
  dfs(1, 0);
  for (int i = 0; i < q; i++) {
    scanf("%d%d", &u, &v);
    Q[u].push_back(make_pair(v, i));
  }
  solve(1, 0);
  for (int i = 0; i < q; i++) printf("%d\n", ret[i]);
}
