#include <bits/stdc++.h>
template <typename T>
inline void read(T &x) {
  x = 0;
  char c = getchar();
  bool flag = false;
  while (!isdigit(c)) {
    if (c == '-') flag = true;
    c = getchar();
  }
  while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar();
  if (flag) x = -x;
}
using namespace std;
int n;
struct edge {
  int nxt, to;
  char c;
  edge() {}
  edge(int jzp, int zzz, char lsr) { nxt = jzp, to = zzz, c = lsr; }
} e[20100 << 1];
int head[20100], ecnt;
inline void addedge(int from, int to, char c) {
  e[++ecnt] = edge(head[from], to, c);
  head[from] = ecnt;
}
int dfn[20100], dcnt, dedfn[20100];
int f[15][20100];
int fa[20100], siz[20100], dep[20100];
char fac[20100];
struct Info {
  int to, sz;
  char c;
  Info() {}
  Info(int jzp, int zzz, char lsr) { to = jzp, sz = zzz, c = lsr; }
};
vector<Info> ve[20100];
void dfs(int cur, int faa) {
  dfn[cur] = ++dcnt;
  dedfn[dcnt] = cur;
  dep[dcnt] = dep[faa] + 1;
  fa[dcnt] = faa;
  f[0][dcnt] = faa;
  for (int i = 1; i < 15; ++i) f[i][dcnt] = f[i - 1][f[i - 1][dcnt]];
  int nw = dcnt;
  siz[nw] = 1;
  for (int i = head[cur]; i; i = e[i].nxt) {
    int to = e[i].to;
    if (dfn[to] && dfn[to] == faa) continue;
    dfs(to, nw);
    fac[dfn[to]] = e[i].c;
    ve[nw].push_back(Info(dfn[to], siz[dfn[to]], e[i].c));
    ve[dfn[to]].push_back(Info(nw, n - siz[dfn[to]], e[i].c));
    siz[nw] += siz[dfn[to]];
  }
}
inline int get_lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 14; ~i; --i)
    if (dep[f[i][x]] >= dep[y]) x = f[i][x];
  if (x == y) return x;
  for (int i = 14; ~i; --i)
    if (f[i][x] ^ f[i][y]) x = f[i][x], y = f[i][y];
  return fa[x];
}
char s[20100];
inline void get_chain(int x, int y) {
  int lca = get_lca(x, y);
  int stot = 0;
  while (x ^ lca) s[++stot] = fac[x], x = fa[x];
  stot += dep[y] - dep[lca];
  s[stot + 1] = 0;
  while (y ^ lca) s[stot--] = fac[y], y = fa[y];
}
struct node {
  int cur, faa, nwd;
  node() {}
  node(int jzp, int zzz, int lsr) { cur = jzp, faa = zzz, nwd = lsr; }
} stk[20100];
inline void work() {
  int x, y;
  read(x), read(y);
  x = dfn[x], y = dfn[y];
  get_chain(x, y);
  int stop = 0, res = 0;
  stk[stop = 1] = node(x, 0, 1);
  while (stop) {
    int cur = stk[stop].cur, faa = stk[stop].faa, nwd = stk[stop].nwd;
    char nwc = s[nwd];
    --stop;
    if (!nwc) continue;
    ++res;
    for (unsigned int i = 0; i < ve[cur].size(); ++i)
      if (ve[cur][i].to ^ faa) {
        if (ve[cur][i].c < nwc)
          res += ve[cur][i].sz;
        else if (ve[cur][i].c == nwc)
          stk[++stop] = node(ve[cur][i].to, cur, nwd + 1);
      }
  }
  printf("%d\n", res - 1);
}
int main() {
  srand((unsigned)time(0));
  read(n);
  int q;
  read(q);
  for (int i = 1; i < n; ++i) {
    int u, v;
    char ch[3];
    read(u), read(v);
    scanf("%s", ch);
    addedge(u, v, ch[0]), addedge(v, u, ch[0]);
  }
  dfs(rand() % n + 1, 0);
  while (q--) work();
  return 0;
}
