Problem: As we all know, Eleven has special abilities. Thus, Hopper convinced her to close the gate to the Upside Down World with her mind. Upside down monsters like to move between the worlds, so they are going to attack Hopper and Eleven in order to make them stop. The monsters live in the vines. The vines form a tree with n vertices, numbered from 1 through n. There's a lowercase English letter written in each tunnel (edge).

<image>

Upside down is a magical world. There are m types of monsters in upside down, numbered from 1 through m. Each type of monster has a special word that gives them powers. The special word of type i is si. There are q monsters in upside down. Each one is at a junction (vertex) and is going to some other junction. If monster of type k goes from junction i to junction j, the power it gains is the number of times it sees its special world (sk) consecutively in the tunnels. More formally: 

If f(i, j) is the string we get when we concatenate the letters written in the tunnels on the shortest path from i to j, then the power the monster gains is the number of occurrences of sk in f(i, j).

Hopper and Eleven want to get prepared, so for each monster, they want to know the power the monster gains after moving. 

Input

The first line of input contains three integers, n, m and q (2 ≤ n ≤ 105, 1 ≤ m, q ≤ 105).

The next n - 1 lines contain the tunnels (edges). Each line contains two integers v and u (1 ≤ v, u ≤ n, v ≠ u) and a lowercase English letter c, meaning there's a tunnel connecting junctions v and u written c in it. It is guaranteed that the given graph is a tree.

The next m lines contain the special words. i-th line of them contains a single string si (1 ≤ |si| ≤ 105), consisting of lowercase English letters. It is guaranteed that |s1| + |s2| + ... + |sm| ≤ 105).

The next q lines contain the monsters. Each line contains three integers i, j and k (1 ≤ i, j ≤ n, i ≠ j, 1 ≤ k ≤ m), meaning a monster of type k is going from junction number i to junction number j.

Output

Print q lines. i-th line should contain a single integer, the power the i-th monster gains after moving.

Examples

Input

6 4 5
1 6 b
2 3 a
1 2 b
5 3 b
4 5 b
a
b
bb
aa
1 2 1
6 2 3
1 6 2
4 5 4
1 6 2


Output

0
1
1
0
1


Input

10 6 7
1 3 s
10 1 d
2 6 s
5 2 d
7 4 l
8 9 d
8 10 l
7 2 d
8 7 l
dl
dssld
d
d
l
sl
4 5 4
3 7 5
10 6 2
3 1 4
7 5 6
10 9 4
9 8 4


Output

2
2
0
0
0
1
1

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int read() {
  char c = getchar();
  int d = 0, f = 1;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') f = -1;
  for (; c >= '0' && c <= '9'; d = d * 10 + c - 48, c = getchar())
    ;
  return d * f;
}
char Read() {
  char c = getchar();
  while (c < 'a' || c > 'z') c = getchar();
  return c;
}
const double pi = acos(-1);
const int N = 200100;
int n, m, q;
int cnt, head[N], L[N], R[N], mk[N];
char s[N];
struct edge {
  int to, next, c;
} e[N];
void addedge(int x, int y, int c) {
  e[++cnt] = (edge){y, head[x], c};
  head[x] = cnt;
}
struct node1 {
  int ch[26], nxt[26], fail, fa, id;
} a1[N];
int tot1, dep1[N], mk1[N];
void inserta1(int l, int r, int id) {
  int t = 1;
  for (int i = l; i <= r; ++i) {
    int &tt = a1[t].ch[s[i] - 'a'];
    if (!tt) tt = ++tot1, a1[tt].fa = t, dep1[tt] = dep1[t] + 1;
    t = tt;
  }
  if (!a1[t].id) a1[t].id = id, mk1[id] = t;
  mk[id] = a1[t].id;
}
int q1[N], qc1[N];
vector<int> e1[N];
int pos1, dfn1[N][2];
void dfsfail(int x) {
  dfn1[x][0] = ++pos1;
  for (vector<int>::iterator it = e1[x].begin(); it != e1[x].end(); it++)
    dfsfail(*it);
  dfn1[x][1] = pos1;
}
void inita1() {
  for (int i = 0; i <= 25; ++i) a1[0].ch[i] = 1;
  int h = 0, t = 0;
  q1[++t] = 1;
  qc1[t] = 0;
  while (h++ < t) {
    int u = q1[h], c = qc1[h];
    for (int i = 0; i <= 25; ++i)
      if (a1[u].ch[i]) q1[++t] = a1[u].ch[i], qc1[t] = i;
    if (u == 1) continue;
    int v = a1[a1[a1[u].fa].nxt[c]].ch[c];
    for (int i = 0; i <= 25; ++i)
      if (a1[v].ch[i])
        a1[u].nxt[i] = v;
      else
        a1[u].nxt[i] = a1[v].nxt[i];
    a1[u].fail = v;
    e1[a1[u].fail].push_back(u);
  }
  dfsfail(1);
}
int Fa[N], Dep[N];
int sz[N], p[N];
void dfs(int f, int x) {
  p[++p[0]] = x;
  sz[x] = 1;
  for (int i = head[x], y = e[i].to; y; i = e[i].next, y = e[i].to)
    if (y != f && !Dep[y]) dfs(x, y), sz[x] += sz[y];
}
void solve(int la, int x) {
  p[0] = 0;
  dfs(0, x);
  int Sz = sz[x];
  x = 0;
  for (int i = 1; i <= p[0]; ++i)
    if (sz[p[i]] > Sz / 2 && (!x || sz[p[i]] < sz[x])) x = p[i];
  Fa[x] = la;
  Dep[x] = Dep[la] + 1;
  for (int i = head[x], y = e[i].to; y; i = e[i].next, y = e[i].to)
    if (!Dep[y]) solve(x, y);
}
int lca(int x, int y) {
  if (Dep[x] < Dep[y]) swap(x, y);
  while (Dep[x] > Dep[y]) x = Fa[x];
  while (x != y) x = Fa[x], y = Fa[y];
  return x;
}
int ans[N];
struct qint {
  int x, y, L, z, id;
  pair<int, int> xx, yy;
} Q[N];
bool cmp(qint a, qint b) { return a.L < b.L; }
bool cmpz(qint a, qint b) { return a.z < b.z || (a.z == b.z && a.x < b.x); }
vector<pair<int, int> > sq[N];
int t1[N + 1];
void upd1(int x, int s) {
  for (; x <= N; x += x & -x) t1[x] += s;
}
int ask1(int x) {
  int s = 0;
  for (; x >= 1; x -= x & -x) s += t1[x];
  return s;
}
void dfs1(int f, int x, int nd, int lim) {
  upd1(dfn1[nd][0], 1);
  if (!sq[x].empty()) {
    for (vector<pair<int, int> >::iterator it = sq[x].begin();
         it != sq[x].end(); it++) {
      int id = (*it).first, sd = (*it).second;
      ans[id] += ask1(dfn1[sd][1]) - ask1(dfn1[sd][0] - 1);
    }
    sq[x].clear();
  }
  for (int i = head[x], y = e[i].to; y; i = e[i].next, y = e[i].to)
    if (y != f && Dep[y] >= lim) {
      int c = e[i].c;
      int Nd = a1[nd].ch[c];
      if (!Nd) Nd = a1[a1[nd].nxt[c]].ch[c];
      dfs1(x, y, Nd, lim);
    }
  upd1(dfn1[nd][0], -1);
}
void work1() {
  memset(a1, 0, sizeof a1);
  memset(dep1, 0, sizeof dep1);
  memset(mk1, 0, sizeof mk1);
  memset(dfn1, 0, sizeof dfn1);
  pos1 = 0;
  for (int i = 0; i <= tot1; ++i) e1[i].clear();
  tot1 = 1;
  dep1[tot1] = 1;
  for (int i = 1; i <= m; ++i) inserta1(L[i], R[i], i);
  inita1();
  for (int x = 1; x <= q;) {
    int L = Q[x].L;
    int y = x;
    while (y < q && Q[y + 1].L == L) y++;
    for (int i = x; i <= y; ++i)
      sq[Q[i].y].push_back(make_pair(Q[i].id, mk1[mk[Q[i].z]]));
    dfs1(0, L, 1, Dep[L]);
    x = y + 1;
  }
}
struct node2 {
  int ch[26], fa, len;
} a2[N];
int tot2, cur2, p2[N];
int ch2[N][26], dtot2;
pair<int, int> dfn2[N];
pair<int, int> pos2x[N], pos2y[N];
void inserta2(int c, int l, int id) {
  if (a2[cur2].ch[c]) {
    int q = cur2, qc = a2[cur2].ch[c];
    if (a2[qc].len == a2[q].len + 1)
      cur2 = qc;
    else {
      ++tot2;
      a2[tot2].len = a2[q].len + 1;
      memcpy(a2[tot2].ch, a2[qc].ch, sizeof a2[qc].ch);
      a2[tot2].fa = a2[qc].fa;
      a2[qc].fa = tot2;
      for (; q && a2[q].ch[c] == qc; q = a2[q].fa) a2[q].ch[c] = tot2;
      cur2 = tot2;
    }
    return;
  }
  int p = cur2;
  cur2 = ++tot2;
  a2[cur2].len = l;
  int q = p;
  for (; q && !a2[q].ch[c]; q = a2[q].fa) a2[q].ch[c] = cur2;
  if (!q)
    a2[cur2].fa = 1;
  else {
    int qc = a2[q].ch[c];
    if (a2[qc].len == a2[q].len + 1)
      a2[cur2].fa = qc;
    else {
      ++tot2;
      a2[tot2].len = a2[q].len + 1;
      memcpy(a2[tot2].ch, a2[qc].ch, sizeof a2[qc].ch);
      a2[tot2].fa = a2[qc].fa;
      a2[qc].fa = tot2;
      a2[cur2].fa = tot2;
      for (; q && a2[q].ch[c] == qc; q = a2[q].fa) a2[q].ch[c] = tot2;
    }
  }
  p2[cur2] = id;
}
void Dfs2(int x) {
  dfn2[x].first = dfn2[x].second = ++dtot2;
  for (int i = 0; i <= 25; ++i) {
    int u = ch2[x][i];
    if (u) Dfs2(u), dfn2[x].second = dfn2[u].second;
  }
}
void dfs2(int f, int x, int dep, int nd, int lim) {
  if (!sq[x].empty()) {
    for (vector<pair<int, int> >::iterator it = sq[x].begin();
         it != sq[x].end(); it++)
      Q[(*it).first].xx = make_pair(dfn2[nd].first, abs(dep) - 1);
    sq[x].clear();
  }
  for (int i = head[x], y = e[i].to; y; i = e[i].next, y = e[i].to)
    if (y != f && Dep[y] >= lim) {
      if (dep < 0) {
        dfs2(x, y, dep, nd, lim);
        continue;
      }
      int c = e[i].c;
      int Nd = nd, Dep = dep + 1;
      if ((dep - 1) == a2[nd].len) {
        if (ch2[nd][c])
          Nd = ch2[nd][c];
        else
          Dep = -dep;
      } else if (c != s[p2[nd] - (dep - 1)] - 'a')
        Dep = -dep;
      dfs2(x, y, Dep, Nd, lim);
    }
}
int tp2[N], ts2[N];
void work2() {
  cur2 = 1;
  tot2 = 1;
  dtot2 = 0;
  memset(a2, 0, sizeof a2);
  memset(pos2x, 0, sizeof pos2x);
  memset(tp2, 0, sizeof tp2);
  memset(ts2, 0, sizeof ts2);
  memset(p2, 0, sizeof p2);
  memset(ch2, 0, sizeof ch2);
  memset(dfn2, 0, sizeof dfn2);
  for (int i = 1; i <= m; ++i) {
    cur2 = 1;
    for (int j = L[i]; j <= R[i]; ++j) {
      inserta2(s[j] - 'a', j - L[i] + 1, j);
      pos2x[j] = make_pair(cur2, 0);
    }
  }
  for (int i = 2; i <= tot2; ++i) tp2[a2[i].len]++;
  for (int i = 1; i <= tot2; ++i) tp2[i] += tp2[i - 1];
  for (int i = 2; i <= tot2; ++i) ts2[tp2[a2[i].len]--] = i;
  for (int i = tot2 - 1; i >= 1; --i) p2[a2[ts2[i]].fa] = p2[ts2[i]];
  for (int i = 2; i <= tot2; ++i)
    ch2[a2[i].fa][s[p2[i] - a2[a2[i].fa].len] - 'a'] = i;
  Dfs2(1);
  for (int i = 1; i <= m; ++i)
    for (int j = L[i]; j <= R[i]; ++j) pos2x[j] = dfn2[pos2x[j].first];
  for (int x = 1; x <= q;) {
    int L = Q[x].L;
    int y = x;
    while (y < q && Q[y + 1].L == L) y++;
    for (int i = x; i <= y; ++i) sq[Q[i].x].push_back(make_pair(i, 0));
    dfs2(0, L, 1, 1, Dep[L]);
    x = y + 1;
  }
}
const int NN = N * 10;
pair<pair<int, int>, int> opr[NN];
int oprn;
int t2[NN + 1];
void upd2(int x, int s) {
  for (; x <= NN; x += x & -x) t2[x] += s;
}
int ask2(int x) {
  int s = 0;
  for (; x >= 1; x -= x & -x) s += t2[x];
  return s;
}
pair<pair<int, int>, pair<int, int> > w[NN];
int wn;
void solve2() {
  for (int i = 1; i <= m; ++i)
    for (int j = L[i]; j <= R[i]; ++j) {
      w[++wn] =
          make_pair(make_pair(pos2x[j].first, j - L[i] + 1), make_pair(j, 1));
      w[++wn] = make_pair(make_pair(pos2x[j].second, 1e9), make_pair(j, 2));
      w[++wn] =
          make_pair(make_pair(pos2y[j].first, j - L[i] + 1), make_pair(j, 3));
      w[++wn] = make_pair(make_pair(pos2y[j].second, 1e9), make_pair(j, 4));
    }
  for (int i = 1; i <= q; ++i)
    w[++wn] = make_pair(Q[i].xx, make_pair(i, -1)),
    w[++wn] = make_pair(Q[i].yy, make_pair(i, -2));
  sort(w + 1, w + wn + 1);
  int tot = 0;
  for (int i = 1; i <= wn; ++i) {
    tot += (i == 1 || w[i].first != w[i - 1].first);
    pair<int, int> ct = w[i].second;
    if (ct.second == 1) pos2x[ct.first].first = tot;
    if (ct.second == 2) pos2x[ct.first].second = tot;
    if (ct.second == 3) pos2y[ct.first].first = tot;
    if (ct.second == 4) pos2y[ct.first].second = tot;
    if (ct.second == -1) Q[ct.first].x = tot;
    if (ct.second == -2) Q[ct.first].y = tot;
  }
  sort(Q + 1, Q + q + 1, cmpz);
  for (int x = 1; x <= q;) {
    int z = Q[x].z;
    int y = x;
    while (y < q && Q[y + 1].z == z) y++;
    oprn = 0;
    for (int i = L[z]; i <= R[z] - 1; ++i) {
      pair<int, int> A = pos2x[i], B = pos2y[L[z] + R[z] - 1 - i];
      opr[++oprn] = make_pair(make_pair(A.first, B.first), 1);
      opr[++oprn] = make_pair(make_pair(A.first, B.second + 1), -1);
      opr[++oprn] = make_pair(make_pair(A.second + 1, B.first), -1);
      opr[++oprn] = make_pair(make_pair(A.second + 1, B.second + 1), 1);
    }
    sort(opr + 1, opr + oprn + 1);
    int cnt = 1;
    for (int i = x; i <= y; ++i) {
      while (cnt <= oprn && opr[cnt].first.first <= Q[i].x)
        upd2(opr[cnt].first.second + 1, opr[cnt].second), cnt++;
      ans[Q[i].id] += ask2(Q[i].y + 1);
    }
    for (int i = 1; i <= cnt - 1; ++i)
      upd2(opr[i].first.second + 1, -opr[i].second);
    x = y + 1;
  }
}
int main() {
  n = read(), m = read(), q = read();
  for (int i = 2; i <= n; ++i) {
    int x = read(), y = read();
    char c = Read();
    addedge(x, y, c - 'a');
    addedge(y, x, c - 'a');
  }
  for (int i = 1; i <= m; ++i) {
    L[i] = R[i - 1] + 1;
    scanf("%s", s + L[i]);
    R[i] = L[i] + strlen(s + L[i]) - 1;
  }
  solve(0, 1);
  for (int i = 1; i <= q; ++i) {
    int x = read(), y = read(), z = read();
    Q[i].x = x;
    Q[i].y = y;
    Q[i].z = z;
    Q[i].L = lca(Q[i].x, Q[i].y);
    Q[i].id = i;
  }
  sort(Q + 1, Q + q + 1, cmp);
  work1();
  for (int i = 1; i <= m; ++i)
    for (int j = L[i]; j <= (L[i] + R[i]) / 2; ++j)
      swap(s[j], s[L[i] + R[i] - j]);
  for (int i = 1; i <= q; ++i) swap(Q[i].x, Q[i].y);
  work1();
  work2();
  for (int i = 1; i <= m; ++i)
    for (int j = L[i]; j <= (L[i] + R[i]) / 2; ++j)
      swap(s[j], s[L[i] + R[i] - j]);
  for (int i = 1; i <= q; ++i) swap(Q[i].x, Q[i].y), swap(Q[i].xx, Q[i].yy);
  memcpy(pos2y, pos2x, sizeof pos2x);
  work2();
  solve2();
  for (int i = 1; i <= q; ++i) printf("%d\n", ans[i]);
}