C++ DP + KMP
cpp\nint dp[501][51][2][2] = {};\nint dfs(const string &s1, const string &s2, const string &evil, int sp, int ep, bool l1, bool l2, const vector<int> &kmp) {\n 
```cpp\nint dp[501][51][2][2] = {};\nint dfs(const string &s1, const string &s2, const string &evil, int sp, int ep, bool l1, bool l2, const vector<int> &kmp) {\n    if (ep == evil.size())\n        return 0;\n    if (sp == s1.size())\n        return 1;\n    if (!dp[sp][ep][l1][l2]) {\n        for (char ch = (l1 ? s1[sp] : \'a\'); ch <= (l2 ? s2[sp] : \'z\'); ++ch) {\n            auto n_ep = ep;\n            while (n_ep > 0 && ch != evil[n_ep])\n                n_ep = kmp[n_ep - 1];\n            dp[sp][ep][l1][l2] = (dp[sp][ep][l1][l2] + \n                dfs(s1, s2, evil, sp + 1, ch == evil[n_ep] ? n_ep + 1 : 0, \n                    l1 & (ch == s1[sp]), l2 & (ch == s2[sp]), kmp)) % 1000000007;\n        }\n    }\n    return dp[sp][ep][l1][l2];\n}\nint findGoodStrings(int n, string &s1, string &s2, string &evil) {\n    vector<int> kmp(evil.size());\n    for (auto j = 0, i = 1; i < kmp.size(); ++i) {\n        if (evil[i] == evil[j])\n            kmp[i] = ++j;\n        else if (j > 0) {\n            j = kmp[j - 1];\n            --i;\n        }\n    }\n    return dfs(s1, s2, evil, 0, 0, true, true, kmp);\n}\n```
[]