#include <bits/stdc++.h>
using namespace std;
const int iinf = 1e9 + 10;
const long long inf = 1ll << 60;
const long long mod = 1e9 + 7;
void GG() {
  cout << "0\n";
  exit(0);
}
long long mpow(long long a, long long n, long long mo = mod) {
  long long re = 1;
  while (n > 0) {
    if (n & 1) re = re * a % mo;
    a = a * a % mo;
    n >>= 1;
  }
  return re;
}
long long inv(long long b, long long mo = mod) {
  if (b == 1) return b;
  return (mo - mo / b) * inv(mo % b, mo) % mo;
}
const int maxn = 1e6 + 5;
long long fac[maxn], ifac[maxn];
void build() {
  fac[0] = ifac[0] = 1;
  for (int i = 1; i < maxn; ++i)
    fac[i] = fac[i - 1] * (long long)i % mod, ifac[i] = inv(fac[i]);
}
long long C(int a, int b) {
  if (a == -1 && b == -1) return 1;
  if (b > a || b < 0 || a < 0) return 0;
  return fac[a] * ifac[b] % mod * ifac[a - b] % mod;
}
long long first(int L, int c00, int c01, int c10, int c11, bool bef = 0) {
  if (c00 < 0 || c01 < 0 || c10 < 0 || c11 < 0) return 0;
  ++L;
  int n1 = c01 + c11 + (bef == 1), n0 = c00 + c10 + (bef == 0);
  if (L != n1 + n0) {
    ;
    return 0;
  }
  int chg = bef + c01 - c10;
  if (chg < 0 || chg > 1) {
    return 0;
  }
  int por1 = c01 + (bef == 1), por0 = c10 + (bef == 0);
  long long CC = C(n1 - 1, por1 - 1) * C(n0 - 1, por0 - 1) % mod;
  ;
  return CC;
}
long long gt(vector<int> &x, array<array<int, 2>, 2> c) {
  int n = (int)x.size();
  long long re = 0;
  if (c == array<array<int, 2>, 2>{{{0, 0}, {0, 0}}} && (int)x.size() > 1) {
    re++;
  }
  {
    array<array<int, 2>, 2> b = c;
    for (int i = 1; i < n; ++i) {
      if (x[i] == 1) {
        b[x[i - 1]][0]--;
        re = re + first(n - i - 1, b[0][0], b[0][1], b[1][0], b[1][1], 0);
        re %= mod;
        b[x[i - 1]][0]++;
      }
      b[x[i - 1]][x[i]]--;
    }
  }
  {
    for (int L = n - 2; L > 0; --L) {
      re += first(L, c[0][0], c[0][1], c[1][0], c[1][1], 1);
      re %= mod;
    }
  };
  return re;
}
bool isok(vector<int> &x, array<array<int, 2>, 2> c) {
  for (int i = 1; i < (int)x.size(); ++i) {
    c[x[i - 1]][x[i]]--;
  }
  array<array<int, 2>, 2> d = {{{0, 0}, {0, 0}}};
  return c == d;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  build();
  string ra, rb;
  cin >> ra >> rb;
  vector<int> a, b;
  for (char c : ra) a.push_back(c - '0');
  for (char c : rb) b.push_back(c - '0');
  array<array<int, 2>, 2> c;
  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < 2; ++j) cin >> c[i][j];
  long long re = gt(b, c) - gt(a, c);
  ;
  re += isok(b, c);
  re = (re + 2 * mod) % mod;
  cout << re << '\n';
}
