Chefina and swap

from collections import Counter
for j in range(int(input())) :
      e=int(input()) 
      a=list(map(int, input(). split())) 
      
      b=list(map(int, input(). split())) 
      t =[]
      
      c=Counter(a) +Counter(b) 
      for k, l in c. items() :
           if l%2==0:
               continue
           else:
               print(-1)
               break
      else:
         for h in range(0, len(a) ) :
             if a[h] in b:
                  t.append(a[h])
         a = [ele  for ele in a if ele not in t]
         b =[ele for ele in b if ele not in t]
         a=sorted(a) 
         b=sorted(b)
         if len(a) == 0 and len(b)== 0:
             print(0)
         
         else:
            s=0
            lo,lo1=[],[]
            while(s<=len(a)-1) :
               if s%2!=0:
                  lo.append(a[s])
                  lo1.append(b[s])
               s+=1
            
            
            mi=min(min(lo), min(lo1)) 
            count=0
            for g in range(0, len(lo)) :
                if lo[g]==mi or lo1[g] == mi:
                   count=count+1
                else:
                    if min(lo[g],lo1[g]) <= (2*mi):
                      count=count+min(lo[g],lo1[g]) 
                    else:
                      count =count+(2*mi)
            print(count)        
              

Please verify my code
I got wrong answer

Brother,One Piece of Advice i wanna give.Please Post the Link to your WA Submission ,it’s Way more readable! and also Post the link of the Problem! :slightly_smiling_face:

Thanks for reply, bro