#C2073. Distinct Subsequences

    ID: 45349 Type: Default 1000ms 256MiB

Distinct Subsequences

Distinct Subsequences

You are given two strings, S and T. Your task is to determine the number of distinct subsequences of S that equal T. A subsequence is formed by deleting zero or more characters from S without changing the order of the remaining characters. Since the answer can be very large, output it modulo 109+710^9+7.

For example, if S = "rabbbit" and T = "rabbit", there are exactly 33 distinct ways to form T from S.

inputFormat

The input consists of two lines:
- The first line contains the string S.
- The second line contains the target string T.

outputFormat

Output a single integer, the number of distinct subsequences of S equal to T modulo 109+710^9+7.## sample

rabbbit
rabbit
3