#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long N = 100000 + 5;
string a, b;
long long fac[N], ifac[N], cn[4];
long long mpow(long long a, long long b) {
  long long ans = 1;
  for (int i = 1; i <= b; i <<= 1) {
    if (i & b) ans = ans * a % mod;
    a = a * a % mod;
  }
  return ans;
}
long long ncr(int n, int r) {
  if (n == -1 && r == -1) return 1;
  if (n < 0 || r < 0 || r > n) return 0;
  return ((fac[n] * ifac[r] % mod) * ifac[n - r]) % mod;
}
long long go(string& s) {
  int c0 = cn[0], c1 = cn[1], c2 = cn[2], c3 = cn[3];
  long long ans = 0, b, w;
  for (int i = 0; i < s.size() - 1; i++) {
    w = c0 + c2;
    b = i - w;
    if (b != c1 + c3) continue;
    if (c2 == c1) {
      ans += ncr(w - 1, c1 - 1) * ncr(b, c1);
    } else if (c2 == c1 + 1) {
      ans += ncr(w - 1, c2 - 1) * ncr(b, c2 - 1);
    }
    ans %= mod;
  }
  for (int i = 1; i < s.size(); i++) {
    if (s[i] == '1') {
      s[i - 1] == '1' ? c2-- : c0--;
      b = c1 + c3;
      w = s.size() - i - 1 - b;
      if (w == c0 + c2) {
        if (c2 == c1) {
          ans += ncr(w, c1) * ncr(b - 1, c1 - 1);
        } else if (c1 == c2 + 1) {
          ans += ncr(w, c1 - 1) * ncr(b - 1, c1 - 1);
        }
        ans %= mod;
      }
      s[i - 1] == '1' ? c2++ : c0++;
      s[i - 1] == '1' ? c3-- : c1--;
    } else if (i)
      s[i - 1] == '1' ? c2-- : c0--;
  }
  if (c0 == 0 && c1 == 0 && c2 == 0 && c3 == 0) ans++;
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  fac[0] = ifac[0] = 1;
  for (long long i = 1; i < N; i++) {
    fac[i] = fac[i - 1] * i % mod;
    ifac[i] = mpow(fac[i], mod - 2);
  }
  cin >> a >> b;
  cin >> cn[0] >> cn[1] >> cn[2] >> cn[3];
  long long ans = go(b) - go(a);
  for (int i = 1; i < a.size(); i++) {
    if (a[i] == '1') {
      a[i - 1] == '1' ? cn[3]-- : cn[1]--;
    } else {
      a[i - 1] == '1' ? cn[2]-- : cn[0]--;
    }
  }
  if (cn[0] == 0 && cn[1] == 0 && cn[2] == 0 && cn[3] == 0) ans++;
  cout << (ans + mod) % mod << endl;
}
