Below is my code for the Question in January Long Challenge (FAIRELCT - CODE) FAIR ELECTIONS, Even after getting right output for all the cases my answer is not accepted, Can anyone please help me out here. Thank You
t=int(input())
for t in range (t):
n,m = [int(i) for i in input().split()]
A = list(int(i) for i in input().split())[:n]
B = list(int(i) for i in input().split())[:m]
C=min(len(A),len(B))
count=0
for x in range(C):
if sum(A)<sum(B):
count=count+1
mi=A.index(min(A))
ma=B.index(max(B))
d=max(B)
B[ma]=min(A)
A[mi]=d
if sum(A)<=sum(B):
print("-1")
else:
print(count)