#include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 7;
const int N = 2e5;
int n, a[N], c00, c01, c10, c11;
long long P[N], inv[N];
char A[N], B[N];
long long exgcd(long long a, long long b, long long &x, long long &y) {
  long long d = a;
  if (b != 0) {
    d = exgcd(b, a % b, y, x);
    y -= (a / b) * x;
  } else {
    x = 1;
    y = 0;
  }
  return d;
}
long long mod_inv(long long a, long long m) {
  long long x, y;
  exgcd(a, m, x, y);
  return (m + x % m) % m;
}
void init() {
  P[0] = 1;
  inv[0] = 1;
  for (int i = 1; i < N; i++) {
    P[i] = P[i - 1] * i % M;
    inv[i] = mod_inv(P[i], M);
  }
}
long long C(int n, int m) { return P[n] * inv[m] % M * inv[n - m] % M; }
long long cal(int n, int b, int c00, int c01, int c10, int c11) {
  if (c00 < 0 || c01 < 0 || c10 < 0 || c11 < 0) return 0;
  if (b == 0 && !(c01 == c10 || c01 == c10 + 1)) return 0;
  if (b == 1 && !(c10 == c01 || c10 == c01 + 1)) return 0;
  int t = c01 + c10 + 1;
  int t0 = (b == 0) ? (t + 1) / 2 : t / 2;
  int t1 = t - t0;
  if ((c00 > 0 && t0 == 0) || (c11 > 0 && t1 == 0)) return 0;
  int c0 = c00 + t0;
  int c1 = c11 + t1;
  if (n != c0 + c1) return 0;
  long long ans = 1;
  if (c0 > 0) ans *= C(c0 - 1, t0 - 1), ans %= M;
  if (c1 > 0) ans *= C(c1 - 1, t1 - 1), ans %= M;
  return ans;
}
long long dfs(int p, int b, int c00, int c01, int c10, int c11, int lim) {
  if (c00 < 0 || c01 < 0 || c10 < 0 || c11 < 0) return 0;
  if (p < 0) return (c00 == 0 && c01 == 0 && c10 == 0 && c11 == 0);
  if (b == -1) {
    long long ans = 0;
    ans += dfs(p - 1, -1, c00, c01, c10, c11, 0);
    ans += dfs(p - 1, 1, c00, c01, c10, c11, lim);
    ans %= M;
    return ans;
  }
  if (!lim) {
    long long ans = 0;
    ans += cal(p + 1, 0, c00 - (b == 0), c01, c10 - (b == 1), c11);
    ans += cal(p + 1, 1, c00, c01 - (b == 0), c10, c11 - (b == 1));
    ans %= M;
    return ans;
  }
  long long ans = 0;
  ans += dfs(p - 1, 0, c00 - (b == 0), c01, c10 - (b == 1), c11, a[p] == 0);
  if (a[p] == 1)
    ans += dfs(p - 1, 1, c00, c01 - (b == 0), c10, c11 - (b == 1), 1);
  ans %= M;
  return ans;
}
void get(char *s) {
  n = strlen(s);
  for (int i = 0; i < n; i++) {
    a[i] = s[n - 1 - i] - '0';
  }
}
bool check(char *s) {
  int n = strlen(s);
  int a00 = 0, a01 = 0, a10 = 0, a11 = 0;
  for (int i = 1; i < n; i++) {
    if (s[i - 1] == '0' && s[i] == '0') a00++;
    if (s[i - 1] == '0' && s[i] == '1') a01++;
    if (s[i - 1] == '1' && s[i] == '0') a10++;
    if (s[i - 1] == '1' && s[i] == '1') a11++;
  }
  return a00 == c00 && a01 == c01 && a10 == c10 && a11 == c11;
}
int main() {
  init();
  scanf("%s %s %d %d %d %d", A, B, &c00, &c01, &c10, &c11);
  long long ans = 0;
  get(B);
  ans += dfs(n - 1, -1, c00, c01, c10, c11, 1);
  get(A);
  ans -= dfs(n - 1, -1, c00, c01, c10, c11, 1);
  ans += check(A);
  ans += M;
  ans %= M;
  printf("%lld\n", ans);
}
