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):
#!/usr/bin/env python3

n = int(input())
s = input()
t = []
l = []
for i in range(n):
    t.append("S")

for i in range(n):
    if i+1 <= n-1:
        if (s[i] == "x" and t[i] == "S") or (s[i] == "o" and t[i] == "W"):
            if t[i-1] == "S":
                t[i+1] = "W"

            else:
                t[i+1] = "S"

        else:
            t[i+1] = t[i]
    else:
        if ((s[i] == "x" and t[i] == "S") or (s[i] == "o" and t[i] == "W")) and t[0] == t[i-1]: t = "-1"
        elif ((s[i] == "x" and t[i] == "W") or (s[i] == "o" and t[i] == "S")) and t[0] != t[i-1]: t = "-1"
        
for i in range(n):
    l.append("W")

for i in range(n):
    if i+1 <= n-1:
        if (s[i] == "x" and l[i] == "S") or (s[i] == "o" and l[i] == "W"):
            if l[i-1] == "S":
                l[i+1] = "W"

            else:
                l[i+1] = "S"

        else:
            l[i+1] = l[i]

    else:
        if(s[i] == "x" and l[i] == "S") or (s[i] == "o" and l[i] == "W") and t[0] == l[i-1]: l = "-1"
        elif (s[i] == "x" and l[i] == "W") or (s[i] == "o" and l[i] == "S") and t[0] != l[i-1]: l = "-1"
if t != "-1" and l == "-1":
    for i in t:
        print(i,end ="")

elif t == "-1" and l != "-1":
    for i in l:
        print(i,end ="")

elif t == l:print("-1")
else:
    for i in t:
        print(i,end ="")


Fixed, accepted submission:
def judge():
    for i in range(1, n):
        before = list[i-1]
        l = s[i]
        if l == 'o':
            if list[i] == 'S':
                if before == 'S':
                    list.append('S')
                else:
                    list.append('W')
            else:
                if before == 'S':
                    list.append('W')
                else:
                    list.append('S')
        else:
            if list[i] == 'S':
                if before == 'S':
                    list.append('W')
                else:
                    list.append('S')
            else:
                if before == 'S':
                    list.append('S')
                else:
                    list.append('W')
    if list[0] == list[n]:
        if list[0] == 'S':
            if s[0] == 'o' and list[1] == list[n-1] or s[0] == 'x' and list[1] != list[n-1]:
                list.pop()
                print("".join(list))
                exit()
        elif list[0] == 'W':
            if s[0] == 'x' and list[1] == list[n-1] or s[0] == 'o' and list[1] != list[n-1]:
                list.pop()
                print("".join(list))
                exit()

n = int(input())
s = input()

list = ['S', 'S']
judge()
list.clear()
list = ['S', 'W']
judge()
list.clear()
list = ['W', 'S']
judge()
list.clear()
list = ['W', 'W']
judge()
list.clear()
print('-1')