func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 5e5 + 10, C = 30;   int nex[N][C], p, n, par[N], dfa[N][C];   string s, t;   vector<pair<int, char> > adj_matrix[N];   long long ans;   void dfs(int v, int p, int state) {     if (state == (int)t.size()) ans++;     for (auto pa : adj_matrix[v]) {       int u = pa.first;       char c = pa.second;       if (u == p) continue;       dfs(u, v, nex[state][c -  a ]);     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n;     int cur = n + 1;     for (int i = 1; i < n; i++) {       cin >> p;       p--;       cin >> s;       int j = 0, lp = p;       while (j + 1 < s.size()) {         adj_matrix[lp].push_back({cur, s[j]});         lp = cur;         j++;         cur++;       }       adj_matrix[lp].push_back({i, s[j]});     }     cin >> t;     nex[0][t[0] -  a ] = 1;     int l = 0;     for (int i = 1; i <= (int)t.size(); i++) {       for (int j = 0; j < 28; j++) {         if (i < (int)t.size()) {           if (j == (t[i] -  a ))             nex[i][j] = i + 1;           else             nex[i][j] = nex[l][j];         } else           nex[i][j] = nex[l][j];       }       if (i < (int)t.size()) l = nex[l][t[i] -  a ];     }     dfs(0, 0, 0);     cout << ans <<   n ;   }   