#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int s = 0;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) s = s * 10 + ch - '0', ch = getchar();
  return s;
}
inline char getch() {
  char ch = getchar();
  while (!islower(ch)) ch = getchar();
  return ch;
}
const int N = 20005;
int n, m, u, v, x, y, c1, c2, ans;
int dfn[N], dep[N], fa[N], dfn_t, pos[N];
int tag[N], len[N], type[N];
char s[N], t[N], fw[N];
vector<pair<int, char> > G[N];
void dfs(int u, int f) {
  dep[u] = dep[f] + 1, fa[u] = f;
  dfn[u] = ++dfn_t, pos[dfn_t] = u;
  for (auto v : G[u]) {
    if (v.first == f) continue;
    fw[v.first] = v.second;
    dfs(v.first, u);
  }
}
int main() {
  n = read(), m = read();
  for (int i = 1; i < n; i++) {
    u = read(), v = read();
    char c = getch();
    G[u].emplace_back(v, c);
    G[v].emplace_back(u, c);
  }
  dfs(1, 0);
  for (int T = 1; T <= m; T++) {
    memset(s + 1, 0, n * sizeof(char));
    u = x = read(), v = y = read();
    c1 = c2 = 0;
    while (u != v)
      dep[u] > dep[v] ? (s[++c1] = fw[u], u = fa[u])
                      : (t[++c2] = fw[v], v = fa[v]);
    for (; c2;) s[++c1] = t[c2--];
    type[x] = len[x] = 0, tag[x] = T;
    ans = 0;
    for (int i = x; fa[i];) {
      tag[fa[i]] = T, len[fa[i]] = len[i] + 1;
      type[fa[i]] =
          (type[i] ? type[i]
                   : ((fw[i] > s[len[fa[i]]]) - (fw[i] < s[len[fa[i]]])));
      i = fa[i];
      if (type[i] == -1 || (!type[i] && len[i] < c1)) ++ans;
    }
    for (int i = 2; i <= n; i++) {
      u = pos[i];
      if (tag[u] != T) {
        len[u] = len[fa[u]] + 1;
        type[u] = (type[fa[u]] ? type[fa[u]]
                               : ((fw[u] > s[len[u]]) - (fw[u] < s[len[u]])));
        if (type[u] == -1 || (!type[u] && len[u] < c1)) ++ans;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
