// Source code from laekov at noip 2015 day2 #define PRID “substring” #include #include #include using namespace std;
const int maxa = 2003; const int maxb = 203; const int mod = 1e9 + 7;
int n, m, l, f[2][maxb][maxb][2]; char a[maxa], b[maxb];
#define mInc(a,b) { a += b; if (a >= mod) a -= mod; }
int main() { freopen(PRID “.in”, “r”, stdin); freopen(PRID “.out”, “w”, stdout);
scanf("%d%d%d", &n, &m, &l); scanf("%s%s", a, b); memset(f, 0, sizeof(f)); int cur(0), prv(1); f[cur][0][0][0] = 1; for (int i = 0; i < n; ++ i) { swap(cur, prv); memset(f[cur], 0, sizeof(f[cur])); for (int j = 0; j <= m; ++ j) { for (int k = 0; k <= j && k <= l; ++ k) { if (f[prv][j][k][0]) mInc(f[cur][j][k][0], f[prv][j][k][0]); if (f[prv][j][k][1]) mInc(f[cur][j][k][0], f[prv][j][k][1]); } if (j < m && a[i] == b[j]) { for (int k = 0; k <= j && k <= l; ++ k) { if (f[prv][j][k][0] && k < l) mInc(f[cur][j + 1][k + 1][1], f[prv][j][k][0]); if (f[prv][j][k][1]) { if (k < l) mInc(f[cur][j + 1][k + 1][1], f[prv][j][k][1]); mInc(f[cur][j + 1][k][1], f[prv][j][k][1]); } } } } } printf("%d\n", (f[cur][m][l][0] + f[cur][m][l][1])% mod); }