#include <bits/stdc++.h>
using namespace std;
string l, r;
int A, B, C, D, w;
const int N = 100005, mod = 1000000007;
long long fac[N], ifac[N];
inline long long qpow(long long x, int y = mod - 2) {
  long long res = 1;
  for (; y; y >>= 1, x = x * x % mod)
    if (y & 1) res = res * x % mod;
  return res;
}
void init() {
  cin >> l >> r >> A >> B >> C >> D;
  if (B != C && B != C - 1) {
    cout << '0' << endl;
    exit(0);
  }
  w = A + B + C + D;
  if (l.size() > w + 1) {
    cout << '0' << endl;
    exit(0);
  }
  if (r.size() > w + 1) {
    r = "";
    for (int i = 0; i <= w; ++i) r += '1';
  }
  if (r.size() <= w) {
    cout << '0' << endl;
    exit(0);
  }
  fac[0] = 1;
  for (int i = 1; i <= w + 1; ++i) fac[i] = fac[i - 1] * i % mod;
  ifac[w + 1] = qpow(fac[w + 1]);
  for (int i = w; ~i; --i) ifac[i] = ifac[i + 1] * (i + 1) % mod;
  if (l.size() <= w) {
    l = "";
    return;
  }
  for (int i = w; ~i; --i)
    if (l[i] == '0')
      l[i] = '1';
    else {
      l[i] = '0';
      break;
    }
  if (l[0] == '0') {
    l = "";
    return;
  }
}
long long choose(long long n, long long k) {
  if (k == 0) return n == 0;
  if (k < 0 || n < 0) return 0;
  return fac[n + k - 1] * ifac[k - 1] % mod * ifac[n] % mod;
}
long long work(int a, int b, int c, int d) {
  return choose(d, b + 1) * choose(a, c) % mod;
}
long long calc(string &t) {
  if (t.empty()) return 0LL;
  int a = A, b = B, c = C, d = D;
  long long ans = work(a, b, c, d);
  for (int i = 1; i <= w; ++i) {
    int val = 2 * (t[i - 1] - '0') + 1;
    switch (val) {
      case 1:
        --b;
        break;
      case 3:
        --d;
        break;
    }
    if (t[i] == '1') continue;
    ans = (ans - work(a, b, c, d) + mod) % mod;
    switch (val) {
      case 1:
        ++b, --a;
        break;
      case 3:
        ++d, --c;
        break;
    }
  }
  return ans;
}
int main() { init(), cout << (calc(r) - calc(l) + mod) % mod << endl; }
