#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int a, b, c, d, k, ln, s0, s1, d0, d1, lnx, lny, ans, sl[100010], sr[100010],
    fac[100010], ifc[100010];
char S[100010];
int pow(int k, int i) {
  int t = 1;
  while (i) {
    if (i & 1) t = 1ll * t * k % mod;
    k = 1ll * k * k % mod;
    i >>= 1;
  }
  return t;
}
int C(int n, int m) {
  if (n < m) return 0;
  return 1ll * fac[n] * ifc[m] % mod * ifc[n - m] % mod;
}
int cal(int n, int m) {
  if (!n && !m) return 1;
  if (n <= 0 || m <= 0) return 0;
  return C(n - 1, m - 1);
}
int solve(int *s) {
  if (ln > k) return 1ll * cal(s0, d0) * cal(s1, d1) % mod;
  if (ln < k) return 0;
  int ret = 0, nw0 = 0, nw1 = 1, tot0 = 0, tot1 = 1;
  for (int i = 1; i < ln; ++i) {
    if (s[i + 1]) {
      if (!s[i]) {
        ret = (ret +
               1ll * cal(s0 - tot0 - 1, d0 - nw0) * cal(s1 - tot1, d1 - nw1)) %
              mod;
        ret = (ret + 1ll * cal(s0 - tot0 - 1, d0 - nw0 + 1) *
                         cal(s1 - tot1, d1 - nw1)) %
              mod;
      } else {
        ret = (ret +
               1ll * cal(s0 - tot0 - 1, d0 - nw0) * cal(s1 - tot1, d1 - nw1)) %
              mod;
        ret = (ret + 1ll * cal(s0 - tot0 - 1, d0 - nw0 - 1) *
                         cal(s1 - tot1, d1 - nw1)) %
              mod;
      }
    }
    if (s[i + 1]) {
      tot1++;
      if (!s[i]) nw1++;
    } else {
      tot0++;
      if (s[i]) nw0++;
    }
  }
  if (tot0 == s0 && tot1 == s1 && nw0 == d0 && nw1 == d1) ret = (ret + 1) % mod;
  return ret;
}
int main() {
  scanf("%s", S + 1);
  lnx = strlen(S + 1);
  fac[0] = 1;
  for (int i = 1; i <= lnx; ++i) sl[i] = S[i] - '0';
  scanf("%s", S + 1);
  lny = strlen(S + 1);
  for (int i = 1; i <= lny; ++i) sr[i] = S[i] - '0';
  scanf("%d%d%d%d", &a, &b, &c, &d);
  k = a + b + c + d + 1;
  for (int i = 1; i <= k; ++i) fac[i] = 1ll * fac[i - 1] * i % mod;
  ifc[k] = pow(fac[k], mod - 2);
  for (int i = k - 1; i >= 0; --i) ifc[i] = 1ll * ifc[i + 1] * (i + 1) % mod;
  if (lnx > k || lny < k || (b != c && b + 1 != c)) {
    puts("0");
    return 0;
  }
  s0 = a + b + (b != c);
  s1 = c + d + (b == c);
  if (b == c)
    d0 = b, d1 = c + 1;
  else
    d0 = d1 = c;
  ln = lny;
  ans = solve(sr);
  sl[lnx]--;
  ln = lnx;
  while (sl[ln] < 0) sl[ln] += 2, sl[--ln]--;
  if (ln == 1) {
    for (int i = 1; i < lnx; ++i) sl[i] = sl[i + 1];
    lnx--;
  }
  ln = lnx;
  ans -= solve(sl);
  if (ans < 0) ans += mod;
  printf("%d\n", ans);
  return 0;
}
