#include <bits/stdc++.h>
using namespace std;
const int N = 20010;
struct edge {
  int s, t, d, siz, n;
} e[2 * N];
int n, q, h[N], siz[N], s[N][26], df[N], f[N], dep[N], F[N][20], mx[N], A[N],
    len, ans;
int mxlen[N], d[N];
char ch;
void dfs(int x, int fa) {
  siz[x] = 1, F[x][0] = f[x] = fa, dep[x] = dep[fa] + 1;
  for (mx[x] = 0; F[x][mx[x]]; F[x][mx[x] + 1] = F[F[x][mx[x]]][mx[x]], mx[x]++)
    ;
  mx[x]--;
  for (int i = h[x], y; y = e[i].t, i; i = e[i].n)
    if (y != fa)
      dfs(y, x), e[i].siz = siz[y], e[i ^ 1].siz = n - siz[y], siz[x] += siz[y];
    else
      df[x] = e[i].d;
}
int LCA(int x, int y) {
  if (dep[x] > dep[y]) swap(x, y);
  for (int i = mx[y]; i >= 0; i--)
    if (dep[F[y][i]] >= dep[x]) y = F[y][i];
  if (x == y) return x;
  for (int i = mx[x]; i >= 0; i--)
    if (F[x][i] != F[y][i]) x = F[x][i], y = F[y][i];
  return F[x][0];
}
void go(int s, int t, int cnt, int op) {
  while (s != t) A[cnt] = df[s], s = f[s], cnt += op;
}
void dfs(int x, int fa, int pos) {
  if (pos > len) return;
  ans++;
  for (int i = h[x], y; y = e[i].t, i; i = e[i].n)
    if (y != fa) {
      if (e[i].d < A[pos])
        ans += e[i].siz;
      else if (e[i].d == A[pos])
        dfs(y, x, pos + 1);
    }
}
bool checkline() {
  for (int i = 1; i <= n; i++)
    if (d[i] > 2) return 0;
  return 1;
}
void solveline() {
  int X = 0, Y = 0;
  for (int i = 1; i <= n; i++)
    if (d[i] == 1) {
      if (!X)
        X = i;
      else
        Y = i;
    }
  dfs(X, 0), go(Y, X, n - 1, -1), A[0] = A[n] = -1;
  for (int i = 1; i <= n; i++)
    for (mxlen[i] = 0; A[i - 1 - mxlen[i]] == A[i + mxlen[i]]; mxlen[i]++)
      ;
  for (int i = 1, s, t; i <= q; i++) {
    scanf("%d %d", &s, &t), s = dep[s], t = dep[t], ans = 0;
    if (s == t)
      ans = 0;
    else if (s < t) {
      if (s + mxlen[s] < t)
        if (A[s - 1 - mxlen[s]] < A[s + mxlen[s]])
          ans = t - 2;
        else
          ans = (t - s - 1) + mxlen[s];
      else
        ans = 2 * (t - s - 1);
    } else {
      if (s - mxlen[s] > t)
        if (A[s - 1 - mxlen[s]] > A[s + mxlen[s]])
          ans = n - t - 1;
        else
          ans = (s - t - 1) + mxlen[s];
      else
        ans = 2 * (s - t - 1);
    }
    printf("%d\n", ans);
  }
}
void work() {
  scanf("%d %d", &n, &q);
  for (int i = 1, u, v, tot = 1; i < n; i++) {
    scanf("%d %d", &u, &v), d[u]++, d[v]++;
    do ch = getchar();
    while ((ch < 'a') || ('z' < ch));
    e[++tot] = (edge){u, v, ch - 'a', 0, h[u]}, h[u] = tot;
    e[++tot] = (edge){v, u, ch - 'a', 0, h[v]}, h[v] = tot;
  }
  if (checkline()) return solveline();
  dfs(1, 0);
  A[0] = -1;
  for (int i = 1, s, t, lca; i <= q; i++) {
    scanf("%d %d", &s, &t), ans = 0;
    lca = LCA(s, t), len = dep[s] + dep[t] - 2 * dep[lca];
    go(s, lca, 1, 1), go(t, lca, len, -1), A[len + 1] = -1;
    dfs(s, 0, 1);
    printf("%d\n", ans - 1);
  }
}
int main() {
  work();
  return 0;
}
