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;
const int N = 1e5 + 10, lm = 2e5 + 5;
int rd() {
  int x = 0, w = 1;
  char ch = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + (ch ^ 48);
    ch = getchar();
  }
  return x * w;
}
struct BIT {
  int bt[N << 1];
  void add(int x, int y) {
    while (x <= lm) bt[x] += y, x += x & (-x);
  }
  int gsm(int x) {
    int an = 0;
    while (x) an += bt[x], x -= x & (-x);
    return an;
  }
} b1, b2;
char cc[N];
int n, m, q, an[N], qq[N][3], qz[N][2], sta[N], lon[N];
queue<int> qu;
struct TREE {
  int to[N << 1], nt[N << 1], w[N << 1], hd[N], tot;
  TREE() { tot = 1; }
  void clr() { memset(hd, 0, sizeof(int) * (tot + 3)), tot = 1; }
  void adde(int x, int y, int z) {
    ++tot, to[tot] = y, nt[tot] = hd[x], w[tot] = z, hd[x] = tot;
  }
} t1;
struct ACAM {
  int ch[N][26], tn[N][26], fl[N], tt;
  int to[N], nt[N], hd[N], tot, dfn[N], sz[N], ti;
  void adde(int x, int y) { ++tot, to[tot] = y, nt[tot] = hd[x], hd[x] = tot; }
  void clr() {
    while (~tt)
      memset(ch[tt], 0, sizeof(int) * 26),
          fl[tt] = dfn[tt] = sz[tt] = hd[tt] = 0, --tt;
    tt = ti = tot = 0;
  }
  int inst(int l, int r) {
    int x = 0;
    bool fg = l <= r;
    for (int i = l; fg ? i <= r : i >= r; fg ? ++i : --i) {
      int nx = cc[i] - 'a';
      if (!ch[x][nx]) ch[x][nx] = ++tt;
      x = ch[x][nx];
    }
    return x;
  }
  void bui() {
    for (int i = 0; i < 26; ++i)
      if (ch[0][i]) qu.push(ch[0][i]);
    while (!qu.empty()) {
      int x = qu.front();
      qu.pop();
      for (int i = 0; i < 26; ++i) {
        if (ch[x][i])
          fl[ch[x][i]] = ch[fl[x]][i], qu.push(ch[x][i]);
        else
          ch[x][i] = ch[fl[x]][i];
      }
    }
  }
  void dfs(int x) {
    dfn[x] = ++ti, sz[x] = 1;
    for (int i = hd[x]; i; i = nt[i]) {
      int y = to[i];
      dfs(y), sz[x] += sz[y];
    }
  }
  void inii() {
    for (int i = 0; i <= tt; ++i) memcpy(tn[i], ch[i], sizeof(int) * 26);
    bui();
    for (int i = 1; i <= tt; ++i) adde(fl[i], i);
    dfs(0);
  }
} ca, cb;
struct SAM {
  int p[N << 1], tn[N << 1][26], fa[N << 1], len[N << 1], tt;
  int to[N << 1], nt[N << 1], hd[N << 1], tot, sz[N << 1], hs[N << 1],
      top[N << 1], dfn[N << 1], ti;
  int ma[N << 2], st[N][2], tp;
  SAM() { tt = 1; }
  void adde(int x, int y) { ++tot, to[tot] = y, nt[tot] = hd[x], hd[x] = tot; }
  int extd(int xx, int la) {
    int np = ++tt, p = la;
    len[np] = len[p] + 1, la = np;
    while (p && !tn[p][xx]) tn[p][xx] = np, p = fa[p];
    if (!p)
      fa[np] = 1;
    else {
      int q = tn[p][xx];
      if (len[q] == len[p] + 1)
        fa[np] = q;
      else {
        int nq = ++tt;
        fa[nq] = fa[q], len[nq] = len[p] + 1,
        memcpy(tn[nq], tn[q], sizeof(int) * 26);
        fa[np] = fa[q] = nq;
        while (p && tn[p][xx] == q) tn[p][xx] = nq, p = fa[p];
      }
    }
    return np;
  }
  void dfs1(int x) {
    sz[x] = 1;
    for (int i = hd[x]; i; i = nt[i]) {
      int y = to[i];
      dfs1(y), sz[x] += sz[y];
      hs[x] = sz[hs[x]] > sz[y] ? hs[x] : y;
    }
  }
  void dfs2(int x) {
    dfn[x] = ++ti;
    if (hs[x]) top[hs[x]] = top[x], dfs2(hs[x]);
    for (int i = hd[x]; i; i = nt[i]) {
      int y = to[i];
      if (y == hs[x]) continue;
      top[y] = y, dfs2(y);
    }
  }
  void inii(ACAM &ca) {
    queue<int> q;
    for (int i = 0; i < 26; ++i)
      if (ca.tn[0][i]) p[ca.tn[0][i]] = extd(i, 1), q.push(ca.tn[0][i]);
    p[0] = 1;
    while (!q.empty()) {
      int x = q.front();
      q.pop();
      for (int i = 0; i < 26; ++i)
        if (ca.tn[x][i]) p[ca.tn[x][i]] = extd(i, p[x]), q.push(ca.tn[x][i]);
    }
    for (int i = 2; i <= tt; ++i) adde(fa[i], i);
    dfs1(1);
    top[1] = 1, dfs2(1);
  }
  void modif(int o, int l, int r, int lx, int x) {
    if (l == r) {
      ma[o] = x;
      return;
    }
    int mid = (l + r) >> 1;
    if (lx <= mid)
      modif(o << 1, l, mid, lx, x);
    else
      modif(o << 1 | 1, mid + 1, r, lx, x);
    ma[o] = max(ma[o << 1], ma[o << 1 | 1]);
  }
  int quer(int o, int l, int r, int ll, int rr) {
    if (ll <= l && r <= rr) return ma[o];
    int an = 0, mid = (l + r) >> 1;
    if (ll <= mid) an = max(an, quer(o << 1, l, mid, ll, rr));
    if (rr > mid) an = max(an, quer(o << 1 | 1, mid + 1, r, ll, rr));
    return an;
  }
  void mdf(int x, int y) {
    st[++tp][0] = x, st[tp][1] = 0;
    if (!x) return;
    st[tp][1] = quer(1, 1, tt, dfn[x], dfn[x]);
    modif(1, 1, tt, dfn[x], y);
  }
  void wd() {
    int x = st[tp][0], y = st[tp][1];
    --tp;
    if (!x) return;
    modif(1, 1, tt, dfn[x], y);
  }
  int qry(int x) {
    int an = 0;
    while (x) an = max(an, quer(1, 1, tt, dfn[top[x]], dfn[x])), x = fa[top[x]];
    return an;
  }
} sa, sb;
vector<int> qp[N], q1[N], q2[N], sq[N], fq[N];
bool ban[N];
int dp[N], nsz, sz[N], mx, rt;
void fdrt(int x, int ffa) {
  q1[x].clear(), q2[x].clear();
  sz[x] = 1;
  int nm = 0;
  for (int i = t1.hd[x]; i; i = t1.nt[i]) {
    int y = t1.to[i];
    if (ban[y] || y == ffa) continue;
    fdrt(y, x), sz[x] += sz[y];
    nm = max(nm, sz[y]);
  }
  nm = max(nm, nsz - sz[x]);
  if (mx > nm) mx = nm, rt = x;
}
void w1(int x, int ffa) {
  mx = nsz + 1, fdrt(x, 0), x = rt, fdrt(x, 0);
  ban[x] = 1, dp[x] = dp[ffa] + 1;
  for (int i = t1.hd[x]; i; i = t1.nt[i]) {
    int y = t1.to[i];
    if (ban[y]) continue;
    nsz = sz[y], w1(y, x);
  }
  ban[x] = 0;
}
int f1[N][17], d1[N], lz, p1[N][17];
void t1d1(int x) {
  p1[x][0] = x;
  for (int j = 1; j <= lz; ++j) {
    f1[x][j] = f1[f1[x][j - 1]][j - 1],
    p1[x][j] = dp[p1[x][j - 1]] < dp[p1[f1[x][j - 1]][j - 1]]
                   ? p1[x][j - 1]
                   : p1[f1[x][j - 1]][j - 1];
    if (!f1[x][j]) break;
  }
  for (int i = t1.hd[x]; i; i = t1.nt[i]) {
    int y = t1.to[i];
    if (y == f1[x][0]) continue;
    f1[y][0] = x, d1[y] = d1[x] + 1, t1d1(y);
  }
}
int ap1[N], ap2[N];
void t1d2(int x, int ffa, int ax, int bx) {
  b1.add(ca.dfn[ax], 1), b2.add(cb.dfn[bx], 1);
  int nn = q1[x].size();
  for (int i = 0; i < nn; ++i) {
    int j = q1[x][i], px = ap1[qq[j][2]];
    an[j] += b1.gsm(ca.dfn[px] + ca.sz[px] - 1) - b1.gsm(ca.dfn[px] - 1);
  }
  nn = q2[x].size();
  for (int i = 0; i < nn; ++i) {
    int j = q2[x][i], px = ap2[qq[j][2]];
    an[j] += b2.gsm(cb.dfn[px] + cb.sz[px] - 1) - b2.gsm(cb.dfn[px] - 1);
  }
  for (int i = t1.hd[x]; i; i = t1.nt[i]) {
    int y = t1.to[i];
    if (ban[y] || y == ffa) continue;
    t1d2(y, x, ca.ch[ax][t1.w[i]], cb.ch[bx][t1.w[i]]);
  }
  b1.add(ca.dfn[ax], -1), b2.add(cb.dfn[bx], -1);
}
void t1d3(int x, int ffa, int de, int ax, int bx) {
  sa.mdf(ax, de), sb.mdf(bx, de);
  int nn = q1[x].size();
  for (int i = 0; i < nn; ++i) {
    int j = q1[x][i], px = sa.p[ap1[qq[j][2]]];
    qz[j][0] = sa.qry(px);
  }
  nn = q2[x].size();
  for (int i = 0; i < nn; ++i) {
    int j = q2[x][i], px = sb.p[ap2[qq[j][2]]];
    qz[j][1] = sb.qry(px);
  }
  for (int i = t1.hd[x]; i; i = t1.nt[i]) {
    int y = t1.to[i];
    if (ban[y] || y == ffa) continue;
    t1d3(y, x, de + 1, sa.tn[ax][t1.w[i]], sb.tn[bx][t1.w[i]]);
  }
  sa.wd(), sb.wd();
}
void w2(int x) {
  mx = nsz + 1, fdrt(x, 0), x = rt, fdrt(x, 0);
  ban[x] = 1;
  int mm = qp[x].size();
  if (mm) {
    for (int i = 0; i < mm; ++i) {
      int j = qp[x][i];
      q1[qq[j][1]].push_back(j), q2[qq[j][0]].push_back(j);
    }
    t1d2(x, 0, 0, 0);
    t1d3(x, 0, 0, 1, 1);
  }
  for (int i = t1.hd[x]; i; i = t1.nt[i]) {
    int y = t1.to[i];
    if (ban[y]) continue;
    nsz = sz[y], w2(y);
  }
  ban[x] = 0;
}
void ddd(int x, int len) {
  int nn = fq[x].size();
  for (int i = 0; i < nn; ++i) {
    int ii = fq[x][i];
    an[ii] += b1.gsm(cb.dfn[qz[ii][0]]);
  }
  for (int i = ca.hd[x]; i; i = ca.nt[i]) {
    int y = ca.to[i];
    if (y < len)
      b1.add(cb.dfn[len - y], 1), b1.add(cb.dfn[len - y] + cb.sz[len - y], -1);
    ddd(y, len);
    if (y < len)
      b1.add(cb.dfn[len - y], -1), b1.add(cb.dfn[len - y] + cb.sz[len - y], 1);
  }
}
int main() {
  n = rd(), m = rd(), q = rd();
  for (int i = 1; i < n; ++i) {
    int x = rd(), y = rd();
    scanf("%s", cc);
    t1.adde(x, y, cc[0] - 'a'), t1.adde(y, x, cc[0] - 'a');
  }
  sta[1] = 1;
  for (int i = 1; i <= m; ++i) {
    scanf("%s", cc + sta[i]);
    lon[i] = strlen(cc + sta[i]), sta[i + 1] = sta[i] + lon[i];
  }
  nsz = n, w1(1, 0), dp[0] = n + 1;
  lz = log2(n), d1[1] = 1, t1d1(1);
  for (int i = 1; i <= q; ++i) {
    int x = rd(), y = rd(), z = rd();
    sq[z].push_back(i);
    qq[i][0] = x, qq[i][1] = y, qq[i][2] = z;
    int xx = x, yy = y, np = 0;
    if (d1[xx] < d1[yy]) swap(xx, yy);
    for (int j = lz; ~j; --j)
      if (d1[f1[xx][j]] >= d1[yy])
        np = dp[np] < dp[p1[xx][j]] ? np : p1[xx][j], xx = f1[xx][j];
    for (int j = lz; ~j; --j)
      if (f1[xx][j] != f1[yy][j]) {
        np = dp[np] < dp[p1[xx][j]] ? np : p1[xx][j], xx = f1[xx][j];
        np = dp[np] < dp[p1[yy][j]] ? np : p1[yy][j], yy = f1[yy][j];
      }
    if (xx != yy) {
      np = dp[np] < dp[p1[xx][0]] ? np : p1[xx][0], xx = f1[xx][0];
      np = dp[np] < dp[p1[yy][0]] ? np : p1[yy][0], yy = f1[yy][0];
    }
    np = dp[np] < dp[p1[xx][0]] ? np : p1[xx][0];
    qp[np].push_back(i);
  }
  for (int i = 1; i <= m; ++i) {
    ap1[i] = ca.inst(sta[i], sta[i] + lon[i] - 1);
    ap2[i] = cb.inst(sta[i] + lon[i] - 1, sta[i]);
  }
  ca.inii(), cb.inii();
  sa.inii(ca), sb.inii(cb);
  nsz = n, w2(1);
  for (int i = 1; i <= m; ++i) {
    ca.clr();
    ca.inst(sta[i], sta[i] + lon[i] - 1), ca.inii();
    cb.clr();
    cb.inst(sta[i] + lon[i] - 1, sta[i]), cb.inii();
    for (int j = 1; j <= lon[i]; ++j) fq[j].clear();
    int nn = sq[i].size();
    for (int j = 0; j < nn; ++j) {
      int x = sq[i][j];
      if (qz[x][0] && qz[x][1]) fq[qz[x][1]].push_back(x);
    }
    ddd(0, lon[i]);
  }
  for (int i = 1; i <= q; ++i) printf("%d\n", an[i]);
  return 0;
}