#include <bits/stdc++.h>
const int N = 100005, mu = 1000000007;
int p[N], inv[N], n, c00, c01, c10, c11;
char s1[N], s2[N];
int ksm(int x, int y) {
  int ans = 1;
  for (; y; y >>= 1, x = x * 1ll * x % mu)
    if (y & 1) ans = ans * 1ll * x % mu;
  return ans;
}
int C(int x, int y) {
  if (x < y) return 0;
  return 1ll * p[x] * inv[x - y] % mu * inv[y] % mu;
}
int cal(int c00, int c01, int c10, int c11) {
  if (c10 != c01 && c10 != c01 + 1) return 0;
  int t1 = c10 + (c10 == c01), t0 = c10;
  if (c00 == 0 && c01 == 0 && c11 == 0 && c10 == 0) return 1;
  if (t0 == 0 && c00 == 0 && (c11 && t1)) return 1;
  return C(c11 + t1 - 1, t1 - 1) * 1ll * C(c00 + t0 - 1, t0 - 1) % mu;
}
int solve(char s[], int c00, int c01, int c10, int c11, int l, int tag) {
  if (c10 != c01 && c10 != c01 + 1) return 0;
  if (l > c00 + c01 + c10 + c11 + 1) return cal(c00, c01, c10, c11);
  if (l != c00 + c01 + c10 + c11 + 1) return 0;
  int ans = 0;
  for (int i = 2; i <= l; i++) {
    if (s[i] == '0') {
      if (s[i - 1] == '0')
        c00--;
      else
        c10--;
    } else {
      if (s[i - 1] == '0') {
        ans = (ans + cal(c11, c10, c01, c00 - 1)) % mu;
        c01--;
      } else {
        ans = (ans + cal(c11, c10 - 1, c01, c00)) % mu;
        c11--;
      }
    }
  }
  if (c00 || c01 || c11 || c10)
    return ans;
  else
    return (ans + tag) % mu;
}
int main() {
  scanf("%s%s", s2 + 1, s1 + 1);
  scanf("%d%d%d%d", &c00, &c01, &c10, &c11);
  int l1 = strlen(s1 + 1), l2 = strlen(s2 + 1);
  p[0] = 1;
  for (int i = 1; i <= l1; i++) p[i] = 1ll * p[i - 1] * i % mu;
  inv[l1] = ksm(p[l1], mu - 2);
  for (int i = l1; i >= 1; i--) inv[i - 1] = 1ll * inv[i] * i % mu;
  printf("%d\n", (solve(s1, c00, c01, c10, c11, l1, 1) -
                  solve(s2, c00, c01, c10, c11, l2, 0) + mu) %
                     mu);
}
