Stuck at MULTHREE

i’m stuck at solving MULTHREE , i’ve tested it against a lot of test cases and it behaves as expected on my test cases, but it gives me wrong answers and i can’t spot the bug , could you please help me !
Here is my code :
t=int(input())
while(t>0):
k, d0, d1 = map(int, input().split())
d2 = (d0+d1) % 10
if(d2==5):
print(‘NO’)
t-=1
continue
sum_first_digits = d0+d1+d2
num_middle_digits = (k-3)//4
num_last_digits = (k-3) % 4
sum_middle_digits = num_middle_digits20
sum_last_digits = 0
while (num_last_digits > 0):
sum_last_digits +=( (d22) % 10)
d2 = ((d2*2) % 10)
num_last_digits-= 1
total_sum = sum_first_digits+sum_middle_digits+sum_last_digits
if(total_sum% 3 == 0):
print(“YES”)
else:
print(“NO”)
t-=1