#include <bits/stdc++.h>
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#pragma GCC target("popcnt")
using namespace std;
int a, b, c, d;
long long fac[100010], ifac[100010], ans = 0;
const long long p = 1e9 + 7;
char s[100010], t[100010];
template <class T>
void read(T &x) {
  char ch = x = 0;
  bool fl = false;
  while (!isdigit(ch)) fl |= ch == '-', ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  x = fl ? -x : x;
}
long long pw(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = ret * a % p;
    a = a * a % p, b >>= 1;
  }
  return ret;
}
long long C(int a, int b) {
  return a < b || b < 0 ? 0 : fac[a] * ifac[b] % p * ifac[a - b] % p;
}
long long calc(int cnt_0, int adj_0, int cnt_1, int adj_1) {
  if (!cnt_0) return !adj_0 && adj_1 == 1;
  if (!cnt_1) return !adj_1 && adj_0 == 1;
  return C(cnt_0 - 1, adj_0 - 1) * C(cnt_1 - 1, adj_1 - 1) % p;
}
long long solve(char *s) {
  int n = strlen(s + 1), a = ::a, b = ::b, c = ::c, d = ::d;
  long long ret = 0;
  if (n < a + b + c + d + 1) return 0;
  if (n > a + b + c + d + 1) {
    if (b == c) ret = (ret + calc(a + b, b, c + d + 1, b + 1)) % p;
    if (b + 1 == c) ret = (ret + calc(a + b + 1, c, c + d, c)) % p;
    return ret;
  }
  for (int i = 1; i <= n; i++) {
    if (s[i] == '0' || i == 1) {
      if (i > 1) {
        if (s[i - 1] == '0')
          (s[i] == '0' ? a : b)--;
        else
          (s[i] == '0' ? c : d)--;
      }
      continue;
    }
    (s[i - 1] == '0' ? a : c)--;
    swap(a, d), swap(b, c);
    if (b == c) ret = (ret + calc(a + b, b, c + d + 1, b + 1)) % p;
    if (b + 1 == c) ret = (ret + calc(a + b + 1, c, c + d, c)) % p;
    swap(a, d), swap(b, c);
    (s[i - 1] == '0' ? a : c)++;
    if (s[i - 1] == '0')
      (s[i] == '0' ? a : b)--;
    else
      (s[i] == '0' ? c : d)--;
  }
  return ret + (!a && !b && !c && !d);
}
void init() {
  fac[0] = 1;
  for (int i = 1; i < 100010; i++) {
    fac[i] = fac[i - 1] * i % p;
  }
  ifac[100010 - 1] = pw(fac[100010 - 1], p - 2);
  for (int i = 100010 - 2; ~i; i--) {
    ifac[i] = ifac[i + 1] * (i + 1) % p;
  }
}
int main() {
  scanf("%s%s", s + 1, t + 1), init();
  read(a), read(b), read(c), read(d);
  if (strlen(s + 1) > 1) {
    int tmp = strlen(s + 1);
    while (s[tmp] == '0') {
      s[tmp--] = '1';
    }
    s[tmp] = '0', ans = p - solve(s);
  }
  ans = (ans + solve(t)) % p;
  printf("%lld\n", ans);
  return 0;
}
