Getting WA in SKMP problem

I don’t know why i am getting a WA in Smallest KMP problem (problem code: SKMP) as the output is correct but in codechef it is giving WA.
Please help me to understand where i am going wrong and why it is happening.

below is the code written in python language:

try:
    for _ in range(int(input())):
        c=input();
        case2=input();
        s=(sorted(c))
        p=sorted(case2)
    
        i=0;
        while i<(len(p)) : 
           if p[i] in s: s.remove(p[i])
           i=i+1
        
    
        s.append(case2)
        s=sorted(s)
        s="".join(s)
        print(str(s))
       
    
except:
    pass

Here is one test case
1
aabbcc
cbba

Your answer: accbba
Correct answer: acbbac

Try to figure out why your answer is wrong and read the editorial carefully