#include <bits/stdc++.h>
using namespace std;
void File() {
  freopen("CF1045H.in", "r", stdin);
  freopen("CF1045H.out", "w", stdout);
}
template <typename T>
void read(T &_) {
  _ = 0;
  T f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) _ = (_ << 1) + (_ << 3) + (c ^ '0');
  _ *= f;
}
const int maxn = 1e5 + 10;
const long long mod = 1e9 + 7;
const int N = 1e5;
long long fac[maxn], ifac[maxn], sa, sb, sc, sd, ans;
long long qpow(long long x, long long y) {
  long long ret = 1;
  x %= mod;
  while (y) {
    if (y & 1) ret = ret * x % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ret;
}
void Math_Init() {
  fac[0] = 1;
  for (int i = 1, i_end_ = N; i <= i_end_; ++i) fac[i] = fac[i - 1] * i % mod;
  ifac[N] = qpow(fac[N], mod - 2);
  for (int i = N - 1, i_end_ = 0; i >= i_end_; --i)
    ifac[i] = ifac[i + 1] * (i + 1) % mod;
}
long long C(long long x, long long y) {
  if (x < 0 || y < 0) return 1;
  return fac[x] * ifac[y] % mod * ifac[x - y] % mod;
}
long long calc(int a, int b, int c, int d) {
  return C(d + b, b) * C(a + c - 1, c - 1) % mod;
}
long long solve(char *s, bool flag) {
  int len = strlen(s + 1);
  if (len < sa + sb + sc + sd + 1) return 0;
  if (len > sa + sb + sc + sd + 1)
    return C(sd + sb, sb) * C(sa + sc - 1, sc - 1) % mod;
  long long ret = 0;
  int a = sa, b = sb, c = sc, d = sd;
  for (int i = 1, i_end_ = len; i <= i_end_; ++i) {
    if (i > 2 && s[i - 2] == '0' && s[i - 1] == '0') --a;
    if (i > 2 && s[i - 2] == '0' && s[i - 1] == '1') --b;
    if (i > 2 && s[i - 2] == '1' && s[i - 1] == '0') --c;
    if (i > 2 && s[i - 2] == '1' && s[i - 1] == '1') --d;
    if (a < 0 || b < 0 || c < 0 || d < 0) break;
    if (s[i] == '0' || i == 1) continue;
    if (i > 1) {
      if (s[i - 1] == '0')
        --a;
      else
        --c;
    }
    if (c >= b - 1 && c <= b && a >= 0 && b >= 1 && c >= 0 && d >= 0) {
      ret = (ret + C(d + b - 1, b - 1) * C(a + c, c) % mod) % mod;
    }
    if (i > 1) {
      if (s[i - 1] == '0')
        ++a;
      else
        ++c;
    }
  }
  if (len > 1 && s[len - 1] == '0' && s[len] == '0') --a;
  if (len > 1 && s[len - 1] == '0' && s[len] == '1') --b;
  if (len > 1 && s[len - 1] == '1' && s[len] == '0') --c;
  if (len > 1 && s[len - 1] == '1' && s[len] == '1') --d;
  return ret + (!a && !b && !c && !d) * flag;
}
int main() {
  Math_Init();
  char s[maxn], t[maxn];
  scanf("%s%s", s + 1, t + 1);
  read(sa), read(sb), read(sc), read(sd);
  if (sb > sc || sb < sc - 1) return puts("0"), 0;
  ans = solve(t, 1) - solve(s, 0);
  printf("%lld\n", (ans % mod + mod) % mod);
  return 0;
}
