#include <bits/stdc++.h>   const int mod = 1000000007;   using namespace std;   int dp[5009][5009];   char s1[5009], s2[5009];   int main() {     while (scanf( %s%s , s1, s2) == 2) {       memset(dp, 0, sizeof(dp));       int len2 = strlen(s2);       for (int i = 1; s1[i - 1]; i++) {         for (int j = 1; s2[j - 1]; j++) {           if (s1[i - 1] == s2[j - 1]) {             dp[i][j] = (dp[i - 1][j - 1] + dp[i][j - 1] + 1) % mod;           } else             dp[i][j] = dp[i][j - 1];         }       }       int ans = 0;       for (int i = 1; s1[i - 1]; i++) ans = (ans + dp[i][len2]) % mod;       printf( %d n , ans);     }     return 0;   }   