#include <bits/stdc++.h>
using namespace std;
int read() {
  int r = 0, t = 1, c = getchar();
  while (c < '0' || c > '9') {
    t = c == '-' ? -1 : 1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    r = (r << 3) + (r << 1) + (c ^ 48);
    c = getchar();
  }
  return r * t;
}
char x[100010], y[100010];
long long a, b, c, d;
long long f[100010], pf[100010], n;
long long C(long long a, long long b) {
  return f[a] * pf[b] % 1000000007 * pf[a - b] % 1000000007;
}
long long calc(long long a, long long b) {
  if (b == 0) return a == 0;
  return C(a + b - 1, b - 1);
}
long long calc(char *s, long long a, long long b, long long c, long long d,
               long long op) {
  while (s[1] == '0') s++;
  long long l = strlen(s + 1);
  if (l <= a + b + c + d) return 0;
  if (b != c && b + 1 != c) return 0;
  if (l > a + b + c + d + 1) {
    return calc(d, b + 1) * calc(a, c);
  }
  long long r = 0;
  for (int i = (2), _end_ = (l); i <= _end_; i++)
    if (s[i] == '0') {
      if (s[i - 1] == '0')
        a--;
      else
        c--;
    } else {
      if (s[i - 1] == '0') {
        if (a > 0)
          if (b == c || b == c + 1)
            r = (r + calc(d, b) * calc(a - 1, c + 1)) % 1000000007;
      } else {
        if (c > 0)
          if (b + 1 == c || b == c) {
            r = (r + calc(d, b) * calc(a, c)) % 1000000007;
          }
      }
      if (s[i - 1] == '0')
        b--;
      else
        d--;
      if (a < 0 || b < 0 || c < 0 || d < 0) break;
    }
  return (r + (a == 0 && b == 0 && c == 0 && d == 0) * op) % 1000000007;
}
long long pow(long long a, long long b, long long m) {
  long long r = 1;
  a %= m;
  while (b) {
    if (b & 1) r = r * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return r;
}
int main() {
  scanf("%s", x + 1);
  scanf("%s", y + 1);
  a = read();
  b = read();
  c = read();
  d = read();
  n = 100001;
  f[0] = 1;
  for (int i = (1), _end_ = (n); i <= _end_; i++)
    f[i] = f[i - 1] * i % 1000000007;
  pf[n] = pow(f[n], 1000000007 - 2, 1000000007);
  for (int i = (n - 1), _end_ = (0); i >= _end_; i--)
    pf[i] = pf[i + 1] * (i + 1) % 1000000007;
  printf("%lld\n",
         (calc(y, a, b, c, d, 1) - calc(x, a, b, c, d, 0) + 1000000007) %
             1000000007);
  return 0;
}
