#include <bits/stdc++.h>
const int N = 201000, MOD = 1000000007;
long long qpow(long long a, long long b) {
  long long c = 1;
  for (; b; b >>= 1, a = a * a % MOD)
    if (b & 1) c = c * a % MOD;
  return c;
}
int fact[N], ifact[N];
int C(int n, int m) {
  if (n < m) return 0;
  return (long long)fact[n] * ifact[m] % MOD * ifact[n - m] % MOD;
}
int n, im, in, m;
int f(int a, int b) {
  if (b == 0) return a == 0;
  return C(a + b - 1, b - 1);
}
int solve(char *s) {
  if (s[0] == '0') return 0;
  int ret = (long long)f(n, in) * f(m, im) % MOD, len = strlen(s);
  if (len > n + m + in + im) return ret;
  if (len < n + m + in + im) return 0;
  int dn = n, dm = m, din = in, dim = im;
  for (int i = 1; i < len; i++) {
    s[i - 1] == '1' ? dm-- : din--;
    if (s[i] == '1') continue;
    ret = (ret - (long long)f(dn, din) * f(dm, dim)) % MOD;
    s[i - 1] == '1' ? dm++ : din++;
    s[i - 1] == '1' ? dim-- : dn--;
  }
  return ret;
}
char A[N], B[N];
void sol(int x) {
  printf("%d\n", x);
  exit(0);
}
void initialize() {
  fact[0] = 1;
  for (int i = 1; i < N; i++) fact[i] = (long long)fact[i - 1] * i % MOD;
  ifact[N - 1] = qpow(fact[N - 1], MOD - 2);
  for (int i = N - 1; i; i--) ifact[i - 1] = (long long)ifact[i] * i % MOD;
  scanf("%s", A), scanf("%s", B);
  scanf("%d%d%d%d", &n, &im, &in, &m);
  im++;
  if (in > im || in < im - 1) sol(0);
  int len = strlen(A), tmp = len - 1;
  while (A[tmp] == '0') tmp--;
  A[tmp] = '0';
  for (int i = tmp + 1; i < len; i++) A[i] = '1';
  if (tmp == 0 && len > 1)
    for (int i = 0; i < len; i++) A[i] = A[i + 1];
}
int main() {
  initialize();
  int ans = solve(B) - solve(A);
  ans = (ans % MOD + MOD) % MOD;
  printf("%d\n", ans);
  return 0;
}
