#include "bits/stdc++.h"
using namespace std;
#define int long long

const int mod = 1e9 + 7;

int cal(int r,int i){
	int zeros = (1LL<<i) - 1, n = (1LL<<(i+1));
	r = max(0LL, r - zeros);
	return r/n *(n/2) + min(r%n,n/2);
}

int rsm(int l,int r,int i){
   return cal(r,i) - cal(l-1,i);
}

int32_t main()
{
   int a,b,c,d; cin >> a >> b >> c >> d;
   int ans = 0;
   for(int i=0;i<31;i++){
   	int onesl = rsm(a,b,i), zerosl = b - a + 1 - onesl;
   	int onesr = rsm(c,d,i), zerosr = d - c + 1 - onesr;
   	ans = ans + (1LL << i) * (onesl * zerosr + onesr * zerosl); 
   	ans %= mod;
    }
    cout << ans;
}