```go
package main
import (
"bufio"
"fmt"
"os"
)
const MOD = 1000000007
func main() {
reader := bufio.NewReader(os.Stdin)
var s, t string
fmt.Fscan(reader, &s)
fmt.Fscan(reader, &t)
n := len(s)
m := len(t)
// Build KMP failure function for t
fail := make([]int, m)
fail[0] = 0
j := 0
for i := 1; i < m; i++ {
for j > 0 && t[i] != t[j] {
j = fail[j-1]
}
if t[i] == t[j] {
j++
}
fail[i] = j
}
// Find all positions in s where t ends (0-indexed end position)
// endPos[i] = true means t ends at position i in s
endPos := make([]bool, n)
j = 0
for i := 0; i < n; i++ {
for j > 0 && s[i] != t[j] {
j = fail[j-1]
}
if s[i] == t[j] {
j++
}
if j == m {
endPos[i] = true
j = fail[j-1]
}
}
// For each position i in s (1-indexed), compute:
// earliest[i] = earliest start position (1-indexed) of a substring ending at or before i that contains t
// i.e., if t ends at position e (0-indexed), then a valid substring containing t
// must start at or before e - m + 2 (1-indexed) and end at or after e+1 (1-indexed)
// Let's think in 1-indexed terms for s.
// If t ends at position e+1 (1-indexed, so e is 0-indexed index),
// then the substring [a, b] contains t if a <= e+1-m+1 = e-m+2 and b >= e+1.
// We need to count sequences of non-overlapping substrings each containing t.
// dp[i] = number of ways to choose substrings from s[1..i] (1-indexed)
// Let dp[i] = number of valid selections where the last substring ends at position i
// Plus a prefix sum approach.
// Actually let's define:
// f[i] = number of ways to select k>=1 non-overlapping substrings from s[1..i]
// where the last one ends exactly at i
// g[i] = sum of f[1..i] = total ways where last substring ends at or before i
// For f[i]: we need to choose the last substring [a, b] with b = i, and it contains t.
// The earliest a can start such that [a, i] contains t is:
// the latest end of t that is <= i, call it lastT[i] (1-indexed end position)
// then a can be from 1 to lastT[i] - m + 1
// The previous substring must end at most a-1.
// So f[i] = sum over a from 1 to maxA[i] of (1 + g[a-1])
// = maxA[i] + sum_{a=1}^{maxA[i]} g[a-1]
// = maxA[i] + sum_{j=0}^{maxA[i]-1} g[j]
// where maxA[i] = lastT[i] - m + 1, and lastT[i] is the largest j<=i where t ends at j (1-indexed)
// Compute lastT array (1-indexed)
lastT := make([]int, n+1) // lastT[i] for i in 1..n
last := -1
for i := 0; i < n; i++ {
if endPos[i] {
last = i + 1 // 1-indexed
}
lastT[i+1] = last
}
// g[i] = total ways with last substring ending at or before i (1-indexed), g[0] = 0
g := make([]int64, n+2)
// prefG[i] = g[0] + g[1] + ... + g[i]
prefG := make([]int64, n+2)
g[0] = 0
prefG[0] = 0
for i := 1; i <= n; i++ {
lt := lastT[i]
var fi int64
if lt == -1 {
fi = 0
} else {
maxA := lt - m + 1
if maxA >= 1 {
// f[i] = maxA + prefG[maxA-1] - prefG[-1]
// = maxA + sum_{j=0}^{maxA-1} g[j]
// = maxA + prefG[maxA-1] (since prefG[j] = g[0]+...+g[j])
fi = (int64(maxA) + prefG[maxA-1]) % MOD
} else {
fi = 0
}
}
g[i] = (g[i-1] + fi) % MOD
prefG[i] = (prefG[i-1] + g[i]) % MOD
}
fmt.Println(g[n])
}
```