Range AND problem doubt

mod = (10**9)+7
def nextPowerOf2(n): 
	count = 0; 

	# First n in the below 
	# condition is for the 
	# case where n is 0 
	if (n and not(n & (n - 1))): 
		return n 
	
	while( n != 0): 
		n >>= 1
		count += 1
	
	return 1 << count



for _ in range(int(input())):
    l,r=map(int,input().split())
    if l==r:
        print(l%mod)
    else:    
        res = nextPowerOf2(l)
        if res==l:
            res = l*2
        if res<=r:
            ans = (l*(res-l))
        else:
            ans = (l*(r-l+1))
        print(ans%mod)

Can someone please tell me where my code goes wrong

1
33 35

WA on this test case!
= (33+32+32)%mod=97 is correct answer

@abhinavverma Ohhhh!! Got it bro , thanks :slight_smile: . Actually i was considering l everytime in computation