#include <bits/stdc++.h>
using namespace std;
template <typename T>
void maxtt(T& t1, T t2) {
  t1 = max(t1, t2);
}
template <typename T>
void mintt(T& t1, T t2) {
  t1 = min(t1, t2);
}
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int& x, int y, int mod = 1000000007) {
  assert(y >= 0);
  x += y;
  if (x >= mod) x -= mod;
  assert(x >= 0 && x < mod);
}
void et(int x = -1) {
  printf("%d\n", x);
  exit(0);
}
long long fastPow(long long x, long long y, int mod = 1000000007) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
long long gcd1(long long x, long long y) { return y ? gcd1(y, x % y) : x; }
char a[100035], b[100035];
int c[5];
int fac[100035], inv[100035];
void initfac(int n) {
  fac[0] = inv[0] = 1;
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    fac[i] = (long long)fac[i - 1] * i % 1000000007;
    inv[i] = fastPow(fac[i], 1000000007 - 2);
  }
}
int C(int n, int m) {
  if (n < m) return 0;
  return (long long)fac[n] * inv[m] % 1000000007 * inv[n - m] % 1000000007;
}
int cal(int len, int st) {
  int all = c[0] + c[1] + c[2] + c[3];
  if (len - 1 != all) return 0;
  if (abs(c[1] - c[2]) > 1) return 0;
  int tmp = 0;
  if (c[1] == c[2]) {
    if (c[1] == 0) {
      if (c[0] == 0 && st == 1) return 1;
      if (c[3] == 0 && st == 0) return 1;
      return 0;
    }
    int ones = c[2] + 1;
    if (st == 1)
      addmod(tmp, (long long)C(c[3] + ones - 1, ones - 1) *
                      C(c[0] + ones - 2, ones - 2) % 1000000007);
    if (st == 0)
      addmod(tmp, (long long)C(c[0] + ones - 1, ones - 1) *
                      C(c[3] + ones - 2, ones - 2) % 1000000007);
  } else {
    if (c[1] + 1 == c[2]) {
      if (st != 1) return 0;
    } else {
      assert(c[2] + 1 == c[1]);
      if (st != 0) return 0;
    }
    int ones = max(c[1], c[2]);
    addmod(tmp, (long long)C(c[3] + ones - 1, ones - 1) *
                    C(c[0] + ones - 1, ones - 1) % 1000000007);
  }
  return tmp;
}
int N;
int dfs(char* s, int i, bool hd, int pre) {
  if (i > N) return 0;
  int len = N - i + 1;
  int tmp = 0;
  int num = s[i] - '0';
  if (num == 1) {
    if (hd) {
      c[pre * 2 + 1]--;
      addmod(tmp, dfs(s, i + 1, 1, 1));
      c[pre * 2 + 1]++;
    } else {
      addmod(tmp, dfs(s, i + 1, 1, 1));
    }
    if (hd) {
      c[pre * 2]--;
      addmod(tmp, cal(len, 0));
      c[pre * 2]++;
    } else {
      int all = c[0] + c[1] + c[2] + c[3];
      if (all + 1 < len) addmod(tmp, cal(all + 1, 1));
    }
  } else {
    if (hd) {
      c[pre * 2]--;
      addmod(tmp, dfs(s, i + 1, 1, 0));
      c[pre * 2]++;
    } else
      addmod(tmp, dfs(s, i + 1, 0, 0));
  }
  return tmp;
}
void fmain(int tid) {
  scanf("%s%s", a + 1, b + 1);
  n = strlen(a + 1);
  m = strlen(b + 1);
  for (int(i) = 0; (i) < (int)(4); (i)++) scanf("%d", c + i);
  initfac(m + 5);
  N = n;
  int A = dfs(a, 1, 0, 0);
  int pos = m;
  while (pos && b[pos] == '1') pos--;
  if (pos == 0) {
    b[0] = '0';
    for (int(i) = 1; (i) <= (int)(m); (i)++) b[i + 1] = '1';
    m++;
  } else {
    b[pos] = '1';
    for (int i = pos + 1; i <= n; i++) b[i] = '0';
  }
  N = m;
  int B = dfs(b, 1, 0, 0);
  addmod(B, 1000000007 - A);
  printf("%d\n", B);
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}
