Problem: Oleg Petrov loves crossword puzzles and every Thursday he buys his favorite magazine with crosswords and other word puzzles. In the last magazine Oleg found a curious puzzle, and the magazine promised a valuable prize for it's solution. We give a formal description of the problem below.

The puzzle field consists of two rows, each row contains n cells. Each cell contains exactly one small English letter. You also are given a word w, which consists of k small English letters. A solution of the puzzle is a sequence of field cells c1, ..., ck, such that:

  * For all i from 1 to k the letter written in the cell ci matches the letter wi;
  * All the cells in the sequence are pairwise distinct;
  * For all i from 1 to k - 1 cells ci and ci + 1 have a common side.



Oleg Petrov quickly found a solution for the puzzle. Now he wonders, how many distinct solutions are there for this puzzle. Oleg Petrov doesn't like too large numbers, so calculate the answer modulo 109 + 7.

Two solutions ci and c'i are considered distinct if the sequences of cells do not match in at least one position, that is there is such j in range from 1 to k, such that cj ≠ c'j.

Input

The first two lines contain the state of the field for the puzzle. Each of these non-empty lines contains exactly n small English letters.

The next line is left empty.

The next line is non-empty and contains word w, consisting of small English letters.

The length of each line doesn't exceed 2 000.

Output

Print a single integer — the number of distinct solutions for the puzzle modulo 109 + 7.

Examples

Input

code
edoc

code


Output

4


Input

aaa
aaa

aa


Output

14

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const long long vs = 26;
const int N = 4e3 + 7, p = 1e9 + 7;
int n, m, h[N], t[2][N], f[2][N], dp[N][N][2][2];
char s[2][N], q[N];
long long ans, w[N];
inline int gethsha(int l, int r) {
  return ((t[0][r] - t[0][l - 1] * w[r - l + 1]) % p + p) % p;
}
inline int gethshb(int l, int r) {
  return ((t[1][r] - t[1][l - 1] * w[r - l + 1]) % p + p) % p;
}
inline int gethshc(int l, int r) {
  return ((f[0][l] - f[0][r + 1] * w[r - l + 1]) % p + p) % p;
}
inline int gethshd(int l, int r) {
  return ((f[1][l] - f[1][r + 1] * w[r - l + 1]) % p + p) % p;
}
inline int gethshh(int l, int r) {
  return ((h[r] - h[l - 1] * w[r - l + 1]) % p + p) % p;
}
int main() {
  scanf("%s%s%s", s[0] + 1, s[1] + 1, q + 1), n = strlen(s[0] + 1),
                                              m = strlen(q + 1), w[0] = 1;
  bool fl = false;
  if (m == 1) {
    for (int i = 1; i <= n; i++)
      if (s[0][i] == q[1]) ans++;
    for (int i = 1; i <= n; i++)
      if (s[1][i] == q[1]) ans++;
    cout << ans << endl;
    return 0;
  }
  if (m == 2) {
    for (int i = 1; i <= n; i++)
      if (s[0][i] == q[1] && s[1][i] == q[2]) ans++;
    for (int i = 1; i <= n; i++)
      if (s[1][i] == q[1] && s[0][i] == q[2]) ans++;
    for (int i = 1; i < n; i++)
      if (s[0][i] == q[1] && s[0][i + 1] == q[2]) ans++;
    for (int i = n; i > 1; i--)
      if (s[0][i] == q[1] && s[0][i - 1] == q[2]) ans++;
    for (int i = 1; i < n; i++)
      if (s[1][i] == q[1] && s[1][i + 1] == q[2]) ans++;
    for (int i = n; i > 1; i--)
      if (s[1][i] == q[1] && s[1][i - 1] == q[2]) ans++;
    cout << ans << endl;
    return 0;
  }
  if (m > n * 2) {
    puts("0");
    return 0;
  }
  for (int i = 1; i <= 2 * n; i++) w[i] = w[i - 1] * vs % p;
  for (int i = 1; i <= m; i++)
    if (q[i] != q[m - i + 1]) fl = 1;
  for (int z = 0; z <= 1; z++) {
    for (int i = 1; i <= n; i++)
      t[z][i] = (t[z][i - 1] * vs + (s[z][i] - 'a')) % p;
    for (int i = n; i >= 1; i--)
      f[z][i] = (f[z][i + 1] * vs + (s[z][i] - 'a')) % p;
  }
  memset(dp, 0, sizeof(dp));
  for (int i = 1; i <= m; i++) h[i] = (h[i - 1] * vs + q[i] - 'a') % p;
  for (int i = 1; i <= n; i++)
    for (int x = 2; x <= min(i, m / 2); x++) {
      if ((gethshc(i - x + 1, i) * w[x] + gethshb(i - x + 1, i)) % p ==
          gethshh(1, 2 * x))
        dp[i][2 * x][1][1] = 1;
      if ((gethshd(i - x + 1, i) * w[x] + gethsha(i - x + 1, i)) % p ==
          gethshh(1, 2 * x))
        dp[i][2 * x][0][1] = 1;
      if (x == m / 2) ans = (ans - dp[i][2 * x][1][1] - dp[i][2 * x][0][1]) % p;
    }
  for (int i = 1; i <= n; i++) {
    if (q[1] == s[0][i]) dp[i][1][0][0]++;
    if (q[1] == s[1][i]) dp[i][1][1][0]++;
  }
  for (int i = 1; i <= n; i++)
    for (int x = 1; x <= m; x++) {
      if (s[0][i] == q[x + 1])
        dp[i][x + 1][0][1] = (dp[i][x + 1][0][1] + dp[i][x][1][0]) % p;
      if (s[1][i] == q[x + 1])
        dp[i][x + 1][1][1] = (dp[i][x + 1][1][1] + dp[i][x][0][0]) % p;
      if (s[0][i + 1] == q[x + 1])
        dp[i + 1][x + 1][0][0] =
            (dp[i + 1][x + 1][0][0] + (dp[i][x][0][0] + dp[i][x][0][1]) % p) %
            p;
      if (s[1][i + 1] == q[x + 1])
        dp[i + 1][x + 1][1][0] =
            (dp[i + 1][x + 1][1][0] + (dp[i][x][1][0] + dp[i][x][1][1]) % p) %
            p;
    }
  for (int i = 0; i <= n; i++) dp[i][0][0][0] = dp[i][0][1][0] = 1;
  for (int i = 0; i <= n; i++)
    for (int x = 0; x <= m; x++) {
      if ((m - x) & 1 || m - x == 2) continue;
      if (i + (m - x) / 2 > n) continue;
      int z = m - x;
      if (x == m) {
        ans = (ans + dp[i][x][0][0] + dp[i][x][0][1] + dp[i][x][1][0] +
               dp[i][x][1][1]) %
              p;
        continue;
      }
      if (z == 2 || x == 0) continue;
      if ((gethshd(i + 1, i + z / 2) + gethsha(i + 1, i + z / 2) * w[z / 2]) %
              p ==
          gethshh(m - z + 1, m))
        ans = (ans + dp[i][x][0][0] + dp[i][x][0][1]) % p;
      if ((gethshc(i + 1, i + z / 2) + gethshb(i + 1, i + z / 2) * w[z / 2]) %
              p ==
          gethshh(m - z + 1, m))
        ans = (ans + dp[i][x][1][0] + dp[i][x][1][1]) % p;
    }
  memset(dp, 0, sizeof(dp));
  for (int i = 1; i <= m / 2; i++) swap(q[i], q[m - i + 1]);
  for (int i = 1; i <= m; i++) h[i] = (h[i - 1] * vs + q[i] - 'a') % p;
  for (int i = 1; i <= n; i++)
    for (int x = 2; x <= min(i, m / 2); x++) {
      if ((gethshc(i - x + 1, i) * w[x] + gethshb(i - x + 1, i)) % p ==
          gethshh(1, 2 * x))
        dp[i][2 * x][1][1] = 1;
      if ((gethshd(i - x + 1, i) * w[x] + gethsha(i - x + 1, i)) % p ==
          gethshh(1, 2 * x))
        dp[i][2 * x][0][1] = 1;
    }
  for (int i = 1; i <= n; i++) {
    if (q[1] == s[0][i]) dp[i][1][0][0]++;
    if (q[1] == s[1][i]) dp[i][1][1][0]++;
  }
  for (int i = 1; i <= n; i++)
    for (int x = 1; x <= m; x++) {
      if (s[0][i] == q[x + 1])
        dp[i][x + 1][0][1] = (dp[i][x + 1][0][1] + dp[i][x][1][0]) % p;
      if (s[1][i] == q[x + 1])
        dp[i][x + 1][1][1] = (dp[i][x + 1][1][1] + dp[i][x][0][0]) % p;
      if (s[0][i + 1] == q[x + 1])
        dp[i + 1][x + 1][0][0] =
            (dp[i + 1][x + 1][0][0] + (dp[i][x][0][0] + dp[i][x][0][1]) % p) %
            p;
      if (s[1][i + 1] == q[x + 1])
        dp[i + 1][x + 1][1][0] =
            (dp[i + 1][x + 1][1][0] + (dp[i][x][1][0] + dp[i][x][1][1]) % p) %
            p;
    }
  for (int i = 0; i <= n; i++) dp[i][0][0][0] = dp[i][0][1][0] = 1;
  for (int i = 0; i <= n; i++)
    for (int x = 0; x <= m; x++) {
      if ((m - x) & 1 || m - x == 2) continue;
      if (i + (m - x) / 2 > n) continue;
      int z = m - x;
      if (x == m) {
        ans = (ans + dp[i][x][0][0] + dp[i][x][0][1] + dp[i][x][1][0] +
               dp[i][x][1][1]) %
              p;
        continue;
      }
      if ((gethshd(i + 1, i + z / 2) + gethsha(i + 1, i + z / 2) * w[z / 2]) %
              p ==
          gethshh(m - z + 1, m))
        ans = (ans + dp[i][x][0][0] + dp[i][x][0][1]) % p;
      if ((gethshc(i + 1, i + z / 2) + gethshb(i + 1, i + z / 2) * w[z / 2]) %
              p ==
          gethshh(m - z + 1, m))
        ans = (ans + dp[i][x][1][0] + dp[i][x][1][1]) % p;
    }
  cout << ans << endl;
  return 0;
}