#include <bits/stdc++.h>
const int Max_N = 100005, Mod = 1000000007;
int Fact[Max_N], Inv_Fact[Max_N];
long long Inv(const int x) {
  return x == 1 ? 1 : (Mod - Mod / x) * Inv(Mod % x) % Mod;
}
long long Binomial(const int x1, const int x2) {
  return x1 == -1 && x2 == -1
             ? 1
             : static_cast<long long>(Fact[x1]) * Inv_Fact[x2] % Mod *
                   Inv_Fact[x1 - x2] % Mod;
}
int calc(const int x, const int a, const int b, const int c, const int d) {
  if (a < 0 || b < 0 || c < 0 || d < 0 ||
      (b != c && (x == 0 ? b != c + 1 : b + 1 != c)))
    return 0;
  return Binomial((x == 0) + a + c - 1, (x == 0) + c - 1) *
         Binomial((x == 1) + b + d - 1, (x == 1) + b - 1) % Mod;
}
int calc(const char A[], int a, int b, int c, int d) {
  if (b != c && b != c + 1 && b + 1 != c) return 0;
  int len = strlen(A);
  if (a + b + c + d == 0) return len != 1;
  if (len - 1 < a + b + c + d) return 0;
  Fact[0] = 1;
  for (int i = 1; i <= len; ++i)
    Fact[i] = static_cast<long long>(Fact[i - 1]) * i % Mod;
  Inv_Fact[len] = Inv(Fact[len]);
  for (int i = len; i; --i)
    Inv_Fact[i - 1] = static_cast<long long>(Inv_Fact[i]) * i % Mod;
  if (len - 1 > a + b + c + d) return calc(1, a, b, c, d);
  int res = 0;
  for (int i = 0; i != len - 1 && a >= 0 && b >= 0 && c >= 0 && d >= 0; ++i) {
    int x = (A[i] - '0') << 1 | (A[i + 1] - '0');
    if (x == 0)
      --a;
    else if (x == 1)
      res = (res + calc(0, a - 1, b, c, d)) % Mod, --b;
    else if (x == 2)
      --c;
    else
      res = (res + calc(0, a, b, c - 1, d)) % Mod, --d;
  }
  return res;
}
char A[Max_N], B[Max_N];
int a, b, c, d;
int main(int argc, char **argv) {
  scanf("%s", A);
  scanf("%s", B);
  scanf("%d %d %d %d", &a, &b, &c, &d);
  for (int i = strlen(B) - 1; i >= 0; --i)
    if (B[i] == '0') {
      B[i] = '1';
      break;
    } else
      B[i] = '0';
  if (B[0] == '0') B[0] = '1', B[strlen(B)] = '0';
  printf("%d", (calc(B, a, b, c, d) + Mod - calc(A, a, b, c, d)) % Mod);
  return 0;
}
