#include <bits/stdc++.h>
using std::cerr;
using std::endl;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int MAXN = 100005;
const int MOD = 1e9 + 7;
int n, a, b, c, d;
int fac[MAXN << 1], invf[MAXN << 1];
char s[MAXN], t[MAXN];
inline int qpow(int x, int y) {
  int ret = 1, tt = x % MOD;
  while (y) {
    if (y & 1) ret = 1ll * ret * tt % MOD;
    tt = 1ll * tt * tt % MOD;
    y >>= 1;
  }
  return ret;
}
inline int C(int n, int m) {
  if (n < 0 || m < 0 || n < m) return 0;
  return 1ll * fac[n] * invf[n - m] % MOD * invf[m] % MOD;
}
int solve() {
  int nowa = a, nowb = b, nowc = c, nowd = d;
  int len = strlen(s + 1);
  if (len < n) return 0;
  if (len > n) {
    if (b != c && b + 1 != c) return 0;
    int zero = c, one = c + (b == c);
    return 1ll * (a == 0 && zero == 0 ? 1 : C(a + zero - 1, zero - 1)) *
           (d == 0 && one == 0 ? 1 : C(d + one - 1, one - 1)) % MOD;
  }
  int ans = 0;
  for (int i = (1); i <= (n); ++i) {
    if (i > 1) {
      if (s[i - 1] == '0') {
        if (s[i] == '0')
          --a;
        else
          --b;
      } else {
        if (s[i] == '0')
          --c;
        else
          --d;
      }
    }
    if (a < 0 || b < 0 || c < 0 || d < 0) break;
    if (i < n) {
      if (s[i + 1] == '0')
        continue;
      else {
        if (s[i] == '0')
          --a;
        else
          --c;
        if (b == c || b == c + 1) {
          int zero = b + (b == c), one = b;
          ans = (ans +
                 1ll * (a == 0 && zero == 0 ? 1 : C(a + zero - 1, zero - 1)) *
                     (d == 0 && one == 0 ? 1 : C(d + one - 1, one - 1))) %
                MOD;
        }
        if (s[i] == '0')
          ++a;
        else
          ++c;
      }
    }
  }
  if (a == 0 && b == 0 && c == 0 && d == 0)
    ans = (ans + (len != 1 || s[1] != '0')) % MOD;
  a = nowa, b = nowb, c = nowc, d = nowd;
  return ans;
}
void init(int n) {
  fac[0] = 1;
  for (int i = (1); i <= (n); ++i) fac[i] = 1ll * fac[i - 1] * i % MOD;
  invf[n] = qpow(fac[n], MOD - 2);
  for (int i = (n - 1); i >= (0); --i)
    invf[i] = 1ll * invf[i + 1] * (i + 1) % MOD;
}
int main() {
  init(200000);
  scanf("%s", s + 1);
  scanf("%s", t + 1);
  int ptr = strlen(s + 1);
  while (s[ptr] == '0') s[ptr--] = '1';
  s[ptr] = '0';
  a = read(), b = read(), c = read(), d = read();
  n = a + b + c + d + 1;
  int ans = (MOD - solve()) % MOD;
  memcpy(s, t, sizeof s);
  ans = (ans + solve()) % MOD;
  printf("%d\n", ans);
  return 0;
}
