d,l,r,k = map(int, input().split()) mod = 10**9+7 P = [0]*(2**d+1) P[0] = 1 for i in range(1, 2**d+1): P[i] = (P[i-1]*i)%mod j = 1 while j <= d: if 2**(j-1) <= l < 2**j: jl = j if 2**(j-1) <= r < 2**j: jr = j j += 1 if (jr-jl)%2 == k%2 and jr-jl <= k <= jr-jl+2*(jl-1): t = k-(jr-jl) ans = 1 for i in range(1, d+1): if i == jr and jl != jr: if t <= 4: ans *= 2**(jr-jl)*P[2**(i-1)-1] else: ans *= 2**(jr-jl+t//2)*P[2**(i-1)-1] ans %= mod continue elif i == jr: ans *= 2**(i-1)*2**(t//2-1)*P[2**(i-1)-2] ans %= mod continue ans *= P[2**(i-1)] ans %= mod else: ans = 0 print(ans)