Problem:
Snuke, who loves animals, built a zoo.  There are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle. The animal numbered i (2≤i≤N-1) is adjacent to the animals numbered i-1 and i+1. Also, the animal numbered 1 is adjacent to the animals numbered 2 and N, and the animal numbered N is adjacent to the animals numbered N-1 and 1.  There are two kinds of animals in this zoo: honest sheep that only speak the truth, and lying wolves that only tell lies.  Snuke cannot tell the difference between these two species, and asked each animal the following question: "Are your neighbors of the same species?" The animal numbered i answered s_i. Here, if s_i is `o`, the animal said that the two neighboring animals are of the same species, and if s_i is `x`, the animal said that the two neighboring animals are of different species.  More formally, a sheep answered `o` if the two neighboring animals are both sheep or both wolves, and answered `x` otherwise. Similarly, a wolf answered `x` if the two neighboring animals are both sheep or both wolves, and answered `o` otherwise.  Snuke is wondering whether there is a valid assignment of species to the animals that is consistent with these responses. If there is such an assignment, show one such assignment. Otherwise, print `-1`.

Incorrect submission (verdict: Wrong Answer):
def add_ans(i,ans,circle):
    if circle[i] == 'o':
        if ans[i] == 'S':
            ans += ans[i-1]

        else:
            if ans[i-1] == 'S':
                ans += 'W'
            else:
                ans += 'S'
            
        
        
    if circle[i] == 'x':
        if ans[i] == 'W':
            ans += ans[i-1]
        
        else:
            if ans[i-1] == 'S':
                ans += 'W'
            else:
                ans += 'S'
            
    return ans
def check_last(ans,circle):
    if circle[0] == 'o':
        if ans[0] == 'S':
            last  = ans[1]

        else:
            if ans[1] == 'S':
                last = 'W'
            else:
                last = 'S'



    if circle[0] == 'x':
        if ans[0] == 'W':
            last = ans[1]

        else:
            if ans[1] == 'S':
                last = 'W'
            else:
                last = 'S'
                
                
    if last == ans[-1]:
        return 1
    else :
        return 0


flag = True
n = int(input())
circle = input()

ans_list = ['SS' , 'SW' , 'WS' , 'WW']
for ans in ans_list:
    for i in range(1,len(circle)):
        ans = add_ans(i,ans,circle)


    if check_last(ans , circle) == 1:
        print(ans)
        flag = False
        break

if flag:
    print('-1')

Fixed, accepted submission:
def add_ans(i,ans,circle):
    if circle[i] == 'o':
        if ans[i] == 'S':
            ans += ans[i-1]

        else:
            if ans[i-1] == 'S':
                ans += 'W'
            else:
                ans += 'S'
            
        
        
    if circle[i] == 'x':
        if ans[i] == 'W':
            ans += ans[i-1]
        
        else:
            if ans[i-1] == 'S':
                ans += 'W'
            else:
                ans += 'S'
            
    return ans
def check_last(ans,circle):
    if circle[0] == 'o':
        if ans[0] == 'S':
            last  = ans[1]

        else:
            if ans[1] == 'S':
                last = 'W'
            else:
                last = 'S'



    elif circle[0] == 'x':
        if ans[0] == 'W':
            last = ans[1]

        else:
            if ans[1] == 'S':
                last = 'W'
            else:
                last = 'S'
                
                
    if circle[-1] == 'o':
        if ans[-1] == 'S':
            first  = ans[-2]

        else:
            if ans[-2] == 'S':
                first = 'W'
            else:
                first = 'S'



    elif circle[-1] == 'x':
        if ans[-1] == 'W':
            first = ans[-2]

        else:
            if ans[-2] == 'S':
                first = 'W'
            else:
                first = 'S'
                
                
    if (last == ans[-1]) & (first == ans[0]):
        return 1
    else :
        return 0


flag = True
n = int(input())
circle = input()

ans_list = ['SS' , 'SW' , 'WS' , 'WW']
for ans in ans_list:
    for i in range(1,len(circle)-1):
        ans = add_ans(i,ans,circle)


    if check_last(ans , circle) == 1:
        print(ans)
        flag = False
        break

if flag:
    print('-1')