Help me in solving XORGAND problem

My issue

It is coming time limit exceeded but I do not know what is wrong in my code

My code

for itt in range(int(input())):
    n = int(input())
    a = list(map(int, input().split(" ")))
    q = int(input())
    for i in range(q):
        l, r, x = map(int, input().split(" "))
        index = 0
        for j in range(l, r + 1):
            if (a[j - 1] ^ x) > (a[j - 1] & x):
                index = index + 1
        
        print(index)

Problem Link: XORGAND Problem - CodeChef

@thebluestreak
for each query u are iterating from l to r which will give u time complexity of O(n^2).
and since n is upto 200000. This will give u tle.