#include <bits/stdc++.h>
using namespace std;
const int maxN = 20005;
struct Edge {
  int v;
  char c;
  int size;
};
int size[maxN];
int depth[maxN];
int parent[maxN];
char letter[maxN];
int sLen;
char s[maxN];
char revS[maxN];
int dfsSize;
int dfs[maxN];
int depthX[maxN];
bool visitedX[maxN];
int cmpX[maxN];
int n, q, ans;
vector<Edge> adj[maxN];
void getString(int u, int v) {
  int sSize = 0;
  int revSSize = 0;
  while (u != v) {
    if (depth[u] > depth[v]) {
      s[sSize++] = letter[u];
      u = parent[u];
    } else {
      revS[revSSize++] = letter[v];
      v = parent[v];
    }
  }
  s[sSize] = 0;
  revS[revSSize] = 0;
  reverse(revS, revS + revSSize);
  strcpy(s + sSize, revS);
  sLen = sSize + revSSize;
}
void dfsFunc(int u = 1) {
  dfs[dfsSize++] = u;
  size[u] = 1;
  for (Edge &e : adj[u]) {
    if (e.v != parent[u]) {
      depth[e.v] = depth[u] + 1;
      parent[e.v] = u;
      letter[e.v] = e.c;
      dfsFunc(e.v);
      size[u] += size[e.v];
      e.size = size[e.v];
    }
  }
  for (Edge &e : adj[u]) {
    if (e.v == parent[u]) {
      e.size = n - size[u];
    }
  }
}
int main() {
  scanf("%d %d", &n, &q);
  int u, v;
  char c;
  for (int i = 0; i < n - 1; i++) {
    scanf("%d %d %c", &u, &v, &c);
    adj[u].push_back(Edge{v, c, 0});
    adj[v].push_back(Edge{u, c, 0});
  }
  dfsSize = 0;
  depth[1] = 0;
  parent[1] = 1;
  dfsFunc();
  for (int i = 0; i < q; i++) {
    scanf("%d %d", &u, &v);
    getString(u, v);
    ans = 0;
    memset(visitedX, 0, sizeof(visitedX));
    visitedX[u] = true;
    depthX[u] = 0;
    cmpX[u] = 0;
    while (parent[u] != u) {
      visitedX[parent[u]] = true;
      depthX[parent[u]] = depthX[u] + 1;
      if (cmpX[u] == 0)
        cmpX[parent[u]] =
            (s[depthX[u]] < letter[u]) - (s[depthX[u]] > letter[u]);
      else
        cmpX[parent[u]] = cmpX[u];
      u = parent[u];
    }
    for (int j = 0; j < n; j++) {
      int curr = dfs[j];
      if (!visitedX[curr]) {
        visitedX[curr] = true;
        depthX[curr] = depthX[parent[curr]] + 1;
        if (cmpX[parent[curr]] == 0)
          cmpX[curr] = (s[depthX[parent[curr]]] < letter[curr]) -
                       (s[depthX[parent[curr]]] > letter[curr]);
        else
          cmpX[curr] = cmpX[parent[curr]];
      }
      if (cmpX[curr] == -1 || (cmpX[curr] == 0 && depthX[curr] < sLen)) ans++;
    }
    ans--;
    printf("%d\n", ans);
  }
  return 0;
}
