#include <bits/stdc++.h>
const int maxL = 100005;
const int Mod = 1000000007;
int fexp(int base, int exp) {
  int res = 1;
  for (; exp; exp >>= 1, base = (unsigned long long)base * base % Mod)
    if (exp & 1) res = (unsigned long long)res * base % Mod;
  return res;
}
inline int getInv(int x) { return fexp(x, Mod - 2); }
char A[maxL], B[maxL];
int a, b, c, d, L;
int Fac[maxL], invFac[maxL];
inline int Choose(int m, int n) {
  return n > m || n < 0 ? 0
                        : (unsigned long long)Fac[m] * invFac[n] % Mod *
                              invFac[m - n] % Mod;
}
int f(int m, int n) { return n == 0 ? m == 0 : Choose(n + m - 1, n - 1); }
int calc(int ta, int tb, int tc, int td) {
  return (unsigned long long)f(ta, tc) * f(td, tb) % Mod;
}
int DP(char *s) {
  int res = calc(a, b, c, d);
  int ta = a, tb = b, tc = c, td = d;
  for (int i = 2; i <= L; ++i) {
    if (s[i] == '0') {
      if (s[i - 1] == '1')
        res = (res + Mod - calc(ta, tb, tc, td - 1)) % Mod;
      else if (s[i - 1] == '0')
        res = (res + Mod - calc(ta, tb, tc - 1, td)) % Mod;
      if (s[i - 1] == '1')
        --tb;
      else
        --ta;
    } else {
      if (s[i - 1] == '1')
        --td;
      else
        --tc;
    }
  }
  return res;
}
int check(char *s) {
  int ta = 0, tb = 0, tc = 0, td = 0;
  for (int i = 2; i <= L; ++i)
    if (s[i - 1] == '0') {
      if (s[i] == '0')
        ++ta;
      else
        ++tb;
    } else {
      if (s[i] == '0')
        ++tc;
      else
        ++td;
    }
  return ta == a && tb + 1 == b && tc == c && td == d;
}
int main() {
  scanf("%s%s%d%d%d%d", A + 1, B + 1, &a, &b, &c, &d);
  L = a + b + c + d + 1;
  ++b;
  if (c > b || c < b - 1) {
    puts("0");
    return 0;
  }
  if (strlen(A + 1) > L || strlen(B + 1) < L) {
    puts("0");
    return 0;
  }
  Fac[0] = 1;
  for (int i = 1; i <= L; ++i)
    Fac[i] = (unsigned long long)Fac[i - 1] * i % Mod;
  invFac[L] = getInv(Fac[L]);
  for (int i = L; i; --i)
    invFac[i - 1] = (unsigned long long)invFac[i] * i % Mod;
  int ans = 0;
  if (strlen(A + 1) == L)
    ans = ((unsigned)ans + 2u * Mod - DP(A) + check(A)) % Mod;
  if (strlen(B + 1) > L) memset(B, '1', sizeof(B));
  (ans += DP(B)) %= Mod;
  printf("%d\n", ans);
  return 0;
}
