#include <bits/stdc++.h>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ') {
  while (!isdigit(ch = getchar()))
    if (ch == '-') f = -1;
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return f * x;
}
const int N = 1e5 + 5, P = 1e9 + 7;
struct T {
  int c[4];
} q;
int n, m, a, b, c, d;
char A[N], B[N];
long long fac[N], ifac[N];
long long C(int n, int m) {
  return 0 <= m && m <= n ? fac[n] * ifac[m] % P * ifac[n - m] % P : 0;
}
long long G(int n, int p, T q) {
  int a = q.c[0], b = q.c[1], c = q.c[2], d = q.c[3];
  if (a < 0 || b < 0 || c < 0 || d < 0 || a + b + c + d != n - 1) return 0;
  if (!b && !c) return !p ? a == n - 1 : d == n - 1;
  if (b == c)
    return !p ? C(a + b, b) * C(d + c - 1, c - 1) % P
              : C(a + b - 1, b - 1) * C(d + c, c) % P;
  if (b == c + 1) return !p ? C(a + b - 1, b - 1) * C(d + b - 1, b - 1) % P : 0;
  if (b + 1 == c) return !p ? 0 : C(a + c - 1, c - 1) * C(d + c - 1, c - 1) % P;
  return 0;
}
int S(int n, char *A, T q, int w) {
  int ret = G(1, 0, q);
  for (int i = 1; i < n; ++i) ret = (ret + G(i, 1, q)) % P;
  for (int i = 2; i <= n; ++i) {
    if (A[i] == '1')
      --q.c[(A[i - 1] - '0') << 1], ret = (ret + G(n - i + 1, 0, q)) % P,
                                    ++q.c[(A[i - 1] - '0') << 1];
    --q.c[(A[i - 1] - '0') << 1 | (A[i] - '0')];
  }
  if (!q.c[0] && !q.c[1] && !q.c[2] && !q.c[3]) ret = (ret + w) % P;
  return ret;
}
long long inv(int i) { return i == 1 ? 1 : P - (P / i) * inv(P % i) % P; }
int main() {
  scanf("%s", A + 1), n = strlen(A + 1), scanf("%s", B + 1), m = strlen(B + 1);
  fac[0] = 1;
  for (int i = 1; i <= m; ++i) fac[i] = fac[i - 1] * i % P;
  ifac[m] = inv(fac[m]);
  for (int i = m; i; --i) ifac[i - 1] = ifac[i] * i % P;
  for (int i = 0; i < 4; ++i) q.c[i] = read();
  printf("%d\n", (S(m, B, q, 1) - S(n, A, q, 0) + P) % P);
  return 0;
}
