#include <bits/stdc++.h>   using namespace std;   char a[5005], b[5005];   int la, lb;   int memo[5005][5005];   int dp(int x, int y) {     if (x == la || y == lb)       return 0;     else if (memo[x][y] != -1) {       return memo[x][y];     } else {       int ans1 = dp(x, y + 1) % 1000000007;       int ans2 = 0;       if (a[x] == b[y]) {         ans2 = (dp(x + 1, y + 1) + 1) % 1000000007;       }       int ret = (ans1 + ans2) % 1000000007;       return memo[x][y] = ret;     }   }   int main() {     scanf( %s %s , a, b);     memset(memo, -1, sizeof(memo));     int i;     la = strlen(a);     lb = strlen(b);     int ans = 0;     for (i = 0; i < la; i++) {       ans = (ans + dp(i, 0)) % 1000000007;     }     printf( %d n , ans);     return 0;   }   