Source Code
it=int(input())
for i in range(it):
    size=int(input())
    a =input()
    b =input()
    i = 0
    while a != b:
        if a[i] != b[i]:
            t = b.find(a[i])
            b = b[t:] + b[0:t]
        i += 1
    print(i)
Copy
Split and Swap azoz1111111
Python 3
62 ms
3.1 MB
Runtime Error