#include <bits/stdc++.h>
using namespace std;
void qmax(int &x, int y) {
  if (x < y) x = y;
}
void qmin(int &x, int y) {
  if (x > y) x = y;
}
inline int read() {
  char s;
  int k = 0, base = 1;
  while ((s = getchar()) != '-' && s != EOF && !(isdigit(s)))
    ;
  if (s == EOF) exit(0);
  if (s == '-') base = -1, s = getchar();
  while (isdigit(s)) k = k * 10 + (s ^ '0'), s = getchar();
  return k * base;
}
inline void write(long long x) {
  static char cnt, num[20];
  cnt = 0;
  if (!x) {
    putchar('0');
    return;
  }
  for (; x; x /= 10) num[++cnt] = x % 10;
  for (; cnt; putchar(num[cnt--] + 48))
    ;
}
const long long mod = 1e9 + 7;
const int maxn = 1e5 + 100;
char s1[maxn], s2[maxn];
int A, B, C, D, ls1, ls2, n;
long long ny[maxn], jie[maxn];
long long Ca(int x, int y) { return jie[x] * ny[y] % mod * ny[x - y] % mod; }
long long ans1, ans2;
long long ksm(long long x, int y) {
  long long sum = 1;
  while (y) {
    if (y & 1) sum = sum * x % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return sum;
}
long long work(int a, int b, int c, int d, int len, int tag) {
  if (a < 0 || b < 0 || c < 0 || d < 0 || len <= 0) return 0;
  if (len != a + b + c + d + 1) return 0;
  int c1, c0, d1, d0;
  if (len == 1) return 1;
  if (!a && !b && !c && !tag) return 0;
  if (!d && !b && !c && tag) return 0;
  if (a + 1 == len) return 1;
  if (d + 1 == len) return 1;
  if (tag) {
    if (b == c) {
      c1 = d + b + 1, c0 = a + b, d0 = b, d1 = b + 1;
      return Ca(c1 - 1, d1 - 1) * Ca(c0 - 1, d0 - 1) % mod;
    } else if (c == b + 1) {
      c1 = d + b + 1, c0 = a + b + 1, d0 = b + 1, d1 = b + 1;
      return Ca(c1 - 1, d1 - 1) * Ca(c0 - 1, d0 - 1) % mod;
    } else
      return 0;
  } else {
    if (b == c) {
      c1 = d + b, c0 = a + b + 1, d0 = b + 1, d1 = b;
      return Ca(c1 - 1, d1 - 1) * Ca(c0 - 1, d0 - 1) % mod;
    } else if (c == b - 1) {
      c1 = d + b, c0 = a + b, d0 = b, d1 = b;
      return Ca(c1 - 1, d1 - 1) * Ca(c0 - 1, d0 - 1) % mod;
    } else
      return 0;
  }
}
int main() {
  scanf("%s", s1 + 1);
  scanf("%s", s2 + 1);
  ls1 = strlen(s1 + 1);
  ls2 = strlen(s2 + 1);
  n = ls2 + 10;
  jie[0] = 1;
  for (int i = 1; i <= n; i++) jie[i] = jie[i - 1] * i % mod;
  ny[n] = ksm(jie[n], mod - 2);
  for (int i = n; i >= 1; i--) ny[i - 1] = ny[i] * i % mod;
  A = read(), B = read(), C = read(), D = read();
  if (!A && !B && !C && !D) {
    if (ls1 == 1)
      cout << 1;
    else
      cout << 0;
    return 0;
  }
  if (ls1 > A + B + C + D + 1) {
    ans1 = work(A, B, C, D, A + B + C + D + 1, 1);
  }
  if (ls2 > A + B + C + D + 1) {
    ans2 = work(A, B, C, D, A + B + C + D + 1, 1);
  }
  int AA = A, BB = B, CC = C, DD = D;
  if (A + B + C + D + 1 == ls1) {
    for (int i = 1; i <= ls1; i++) {
      if (i != 1) {
        if (s1[i] == '0' && s1[i - 1] == '0')
          AA--;
        else if (s1[i] == '0' && s1[i - 1] == '1')
          CC--;
        else if (s1[i] == '1' && s1[i - 1] == '1')
          DD--;
        else
          BB--;
      }
      if (i == ls1) break;
      if (AA < 0 || BB < 0 || CC < 0 || DD < 0) break;
      if (s1[i + 1] == '0') continue;
      if (s1[i] == '0') {
        ans1 += work(AA - 1, BB, CC, DD, ls1 - i, 0);
        if (ans1 >= mod) ans1 -= mod;
      } else {
        ans1 += work(AA, BB, CC - 1, DD, ls1 - i, 0);
        if (ans1 >= mod) ans1 -= mod;
      }
    }
  }
  AA = A, BB = B, CC = C, DD = D;
  if (A + B + C + D + 1 == ls2) {
    for (int i = 1; i <= ls2; i++) {
      if (i != 1) {
        if (s2[i] == '0' && s2[i - 1] == '0')
          AA--;
        else if (s2[i] == '0' && s2[i - 1] == '1')
          CC--;
        else if (s2[i] == '1' && s2[i - 1] == '1')
          DD--;
        else
          BB--;
      }
      if (i == ls2) break;
      if (AA < 0 || BB < 0 || CC < 0 || DD < 0) break;
      if (s2[i + 1] == '0') continue;
      if (s2[i] == '0') {
        ans2 += work(AA - 1, BB, CC, DD, ls2 - i, 0);
        if (ans2 >= mod) ans2 -= mod;
      } else {
        ans2 += work(AA, BB, CC - 1, DD, ls2 - i, 0);
        if (ans2 >= mod) ans2 -= mod;
      }
    }
  }
  if (!AA && !BB && !CC && !DD) ans2++;
  ans2 = ans2 - ans1;
  ans2 = (ans2 % mod + mod) % mod;
  cout << ans2 << endl;
  return 0;
}
