CONCATPAL START 77 | Code fails on second task

My code fails on a test case and I am not able to figure out where… Can someone please help me find it?
Here is my code: CodeChef: Practical coding for everyone

It fails for me as well, have you found out why yet?

# cook your dish here

t = int(input())
for _ in range(t):
    N, M = map(int, input().split())
    A = input()
    B = input()
    odd = 0
    C = A + B
    flag = False
    mini = A if N >= M else B
    maxi = B if M > N else A
    for i in mini:
        if i not in maxi:
            flag = True
    if not flag:
        for i in set(C):
            if C.count(i) % 2 != 0: # check if odd
                odd += 1
    if flag:
    elif odd <= 1: