#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int N = 300100;
long long jc[301010], jc_ny[301010];
long long Power(long long x, long long k) {
  long long sss = 1;
  while (k) {
    if (k % 2) sss = sss * x % mod;
    x = x * x % mod;
    k /= 2;
  }
  return sss;
}
long long ny(long long x) { return Power(x, mod - 2); }
long long C(int x, int y) {
  if (x < 0) return 0;
  if (y < 0 || y > x) return 0;
  if (y == 0 || y == x) return 1;
  return jc[x] * jc_ny[x - y] % mod * jc_ny[y] % mod;
}
long long D(int x, int y) {
  if (x == 0) return 1;
  return C(x + y - 1, y - 1);
}
void init() {
  jc[0] = jc_ny[0] = 1;
  for (int i = 1; i <= N; ++i)
    jc[i] = jc[i - 1] * i % mod, jc_ny[i] = ny(jc[i]);
}
char A[101010], B[101010], s[101010];
int a, b, c, d, n;
long long free() {
  if (a + b + c + d == 0) return 1;
  if (b == c)
    return D(a, b) * D(b, d + 1) % mod;
  else if (b + 1 == c)
    return D(d, c) * D(a, c) % mod;
  else
    return 0;
}
int check() {
  int aa = a, bb = b, cc = c, dd = d;
  for (int i = 2; i <= n; ++i) {
    if (s[i - 1] == '0') {
      if (s[i] == '0')
        --aa;
      else
        --bb;
    } else {
      if (s[i] == '0')
        --cc;
      else
        --dd;
    }
  }
  if (aa == 0 && bb == 0 && cc == 0 && dd == 0) return 1;
  return 0;
}
long long sol() {
  if (n == 1) {
    if (a + b + c + d == 0)
      return 1;
    else
      return 0;
  }
  long long sss = 0;
  int doe = a + b + c + d + 1;
  int aa = a, bb = b, cc = c, dd = d;
  if (doe < n)
    return free();
  else if (doe > n)
    return 0;
  else {
    for (int i = 2; i <= n; ++i) {
      if (s[i - 1] == '0')
        --a;
      else
        --c;
      if (a >= 0 && b >= 0 && c >= 0 && d >= 0 && s[i] == '1') {
        if (b == c) (sss += D(d, b) * D(b, a + 1) % mod) %= mod;
        if (b == c + 1) (sss += D(d, b) * D(a, b) % mod) %= mod;
      }
      if (s[i - 1] == '0')
        ++a;
      else
        ++c;
      if (s[i - 1] == '0') {
        if (s[i] == '0')
          --a;
        else
          --b;
      } else {
        if (s[i] == '0')
          --c;
        else
          --d;
      }
    }
  }
  a = aa;
  b = bb;
  c = cc;
  d = dd;
  return sss + check();
}
int main() {
  long long ans = 0;
  init();
  scanf("%s", A + 1);
  scanf("%s", B + 1);
  scanf("%d%d%d%d", &a, &b, &c, &d);
  n = strlen(A + 1);
  for (int i = 1; i <= n; ++i) s[i] = A[i];
  ans -= sol();
  ans += check();
  n = strlen(B + 1);
  for (int i = 1; i <= n; ++i) s[i] = B[i];
  ans += sol();
  printf("%lld\n", (ans % mod + mod) % mod);
  return 0;
}
