Problem:
 Score : 500 points    Problem Statement 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 .      Constraints  3 ≤ N ≤ 10^{5}  s is a string of length N consisting of o and x .         Input The input is given from Standard Input in the following format:  N  s       Output If there does not exist an valid assignment that is consistent with s , print -1 .
Otherwise, print an string t in the following format. The output is considered correct if the assignment described by t is consistent with s .   t is a string of length N consisting of S and W .  If t_i is S , it indicates that the animal numbered i is a sheep. If t_i is W , it indicates that the animal numbered i is a wolf.         Sample Input 1 6
ooxoox      Sample Output 1 SSSWWS  For example, if the animals numbered 1 , 2 , 3 , 4 , 5 and 6 are respectively a sheep, sheep, sheep, wolf, wolf, and sheep, it is consistent with their responses. Besides, there is another valid assignment of species: a wolf, sheep, wolf, sheep, wolf and wolf.  Let us remind you: if the neiboring animals are of the same species, a sheep answers o and a wolf answers x . If the neiboring animals are of different species, a sheep answers x and a wolf answers o .          Sample Input 2 3
oox      Sample Output 2 -1  Print -1 if there is no valid assignment of species.       Sample Input 3 10
oxooxoxoox      Sample Output 3 SSWWSSSWWS

Solution (Python):
def check(li,N):
    for i in range(N):
        if (s[i]=='o' and li[i]==0)or(s[i]=='x' and li[i]==1):
            if(li[(i+1)%N]!=-1 and li[(i+1)%N]!=li[i-1]):
                return False
            else:
                li[(i+1)%N]=li[i-1]
        elif (s[i]=='o' and li[i]==1)or(s[i]=='x' and li[i]==0):
            if(li[(i+1)%N]!=-1 and li[(i+1)%N]==li[i-1]):
                return False
            else:
                li[(i+1)%N]=int(not li[i-1])
    return True
    
def output(li):
    for i in range(N):
        if li[i]==1:
            print('W',end='')
        else:
            print('S',end='')
    print()

N=int(input())
s=input()
for i in range(2):
    for j in range(2):
        li=[-1]*N
        li[0]=i
        if(i==0 and s[0]=='o')or(i==1 and s[0]=='x'):
            li[-1]=j;li[1]=j
        elif(i==1 and s[0]=='o')or(i==0 and s[0]=='x'):
            li[-1]=j;li[1]=j^1
        if(check(li,N)):
            output(li)
            exit()
print(-1)

Solution (Python):
n,s=int(input()),input()
s+=s[:2]

for i in range(2):
    for j in range(2):
        a=[0]*(n+2)
        a[0]=i
        a[1]=j
        for k in range(1,n+1):
            if a[k]==0:
                if s[k]=="o":
                    a[k+1]=a[k-1]
                else:
                    a[k+1]=not a[k-1]
            else:
                if s[k]=="o":
                    a[k+1]=not a[k-1]
                else:
                    a[k+1]=a[k-1]
        if a[0]==a[n] and a[1]==a[n+1]:
            print(*["W" if k else "S" for k in a[:n]],sep="")
            exit()
print(-1)

Solution (Python):
import sys
import queue


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7


def main():
    N = int(input())
    s = input()
    Animal = ["WW", "WS", "SS", "SW"]
    for i in range(1, N - 1):
        if s[i] == "o":
            for j in range(4):
                if Animal[j][-1] == "S":
                    Animal[j] = Animal[j] + Animal[j][-2]
                else:
                    if Animal[j][-2] == "S":
                        Animal[j] = Animal[j] + "W"
                    else:
                        Animal[j] = Animal[j] + "S"
        else:
            for j in range(4):
                if Animal[j][-1] == "S":
                    if Animal[j][-2] == "S":
                        Animal[j] = Animal[j] + "W"
                    else:
                        Animal[j] = Animal[j] + "S"
                else:
                    Animal[j] = Animal[j] + Animal[j][-2]
    for i in range(4):
        animal = Animal[i]
        if s[-1] + s[0] == "xo":
            for a in ["WWWS", "WSSS", "SWSW", "SSWW"]:
                if animal[-2:] + animal[:2] == a:
                    print(animal)
                    return
            else:
                continue

        elif s[-1] + s[0] == "xx":
            for a in ["WWWW", "WSSW", "SWSS", "SSWS"]:
                if animal[-2:] + animal[:2] == a:
                    print(animal)
                    return
                else:
                    continue

        elif s[-1] + s[0] == "ox":
            for a in ["WWSS", "WSWS", "SSSW", "SWWW"]:
                if animal[-2:] + animal[:2] == a:
                    print(animal)
                    return
        elif s[-1] + s[0] == "oo":
            for a in ["WWSW", "WSWW", "SSSS", "SWWS"]:
                if animal[-2:] + animal[:2] == a:
                    print(animal)
                    return
                else:
                    continue
    print(-1)


if __name__ == "__main__":
    main()

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    S = input()

    
    for s0, s1 in [("S", "W"), ("W", "S"), ("S", "S"), ("W", "W")]:
        ans = [None] * N
        ans[0] = s0
        ans[1] = s1
        for i in range(1, N - 1):
            if ans[i] == "S":
                s = S[i]
            else:
                if S[i] == "o":
                    s = "x"
                else:
                    s = "o"

            if s == "o":
                ans[i + 1] = ans[i - 1]
            else:
                if ans[i - 1] == "S":
                    ans[i + 1] = "W"
                else:
                    ans[i + 1] = "S"

        if ans[-1] == "S":
            if S[-1] == "o":
                if ans[-2] == ans[0]:
                    pass
                else:
                    continue
            else:
                if ans[-2] != ans[0]:
                    pass
                else:
                    continue
        else:
            if S[-1] == "o":
                if ans[-2] != ans[0]:
                    pass
                else:
                    continue
            else:
                if ans[-2] == ans[0]:
                    pass
                else:
                    continue

        if ans[0] == "S":
            if S[0] == "o":
                if ans[-1] == ans[1]:
                    print(*ans, sep="")
                    return
                else:
                    continue
            else:
                if ans[-1] != ans[1]:
                    print(*ans, sep="")
                    return
                else:
                    continue
        else:
            if S[0] == "o":
                if ans[-1] != ans[1]:
                    print(*ans, sep="")
                    return
                else:
                    continue
            else:
                if ans[-1] == ans[1]:
                    print(*ans, sep="")
                    return
                else:
                    continue

    else:
        print(-1)


if __name__ == "__main__":
    main()

Solution (Python):
N=int(input())
S=input()
    
for i in range(4):
  ans=[0]*N
  if i==0:
    ans[-1]="S"
    ans[0]="S"
  elif i==1:
    ans[-1]="S"
    ans[0]="W"
  elif i==2:
    ans[-1]="W"
    ans[0]="S"
  else:
    ans[-1]="W"
    ans[0]="W"
  
  for j,s in enumerate(S):
    if j!=N-1 and j!=N-2:
      if ans[j]=="S":
        if s=="o":
          ans[j+1]=ans[j-1]
        else:
          if ans[j-1]=="S":
            ans[j+1]="W"
          else:
            ans[j+1]="S"
      else:
        if s=="x":
          ans[j+1]=ans[j-1]
        else:
          if ans[j-1]=="S":
            ans[j+1]="W"
          else:
            ans[j+1]="S"
    elif j==N-2:
      flag=0
      if ans[N-2]=="S":
        if s=="o":
          if ans[N-1]==ans[N-3]:
            flag=1
        else:
          if ans[N-1]!=ans[N-3]:
            flag=1
      else:
        if s=="x":
          if ans[N-1]==ans[N-3]:
            flag=1
        else:
          if ans[N-1]!=ans[N-3]:
            flag=1
    elif flag:  
      if ans[N-1]=="S":
        if s=="o":
          if ans[N-2]==ans[0]:
            print("".join(ans));exit()
        else:
          if ans[N-2]!=ans[0]:
            print("".join(ans));exit()
      else:
        if s=="x":
          if ans[N-2]==ans[0]:
            print("".join(ans));exit()
        else:
          if ans[N-2]!=ans[0]:
            print("".join(ans));exit()
print(-1)

Solution (Python):
n = int(input())
s = list(input())

ss = [1,1]
sw = [1,-1]
ws = [-1,1]
ww = [-1,-1]
ans = []
for i in range(1,n):
  flag = 1
  if s[i] == "x":
    flag = -1
  if ss[i] == 1:
    ss.append(flag*ss[i-1])
  else:
    ss.append(flag*-ss[i-1])
  if sw[i] == 1:
    sw.append(flag*sw[i-1])
  else:
    sw.append(flag*-sw[i-1])
  if ws[i] == 1:
    ws.append(flag*ws[i-1])
  else:
    ws.append(flag*-ws[i-1])
  if ww[i] == 1:
    ww.append(flag*ww[i-1])
  else:
    ww.append(flag*-ww[i-1])
flag = 1
if s[0] == "x":
  flag = -1
if ss[0] == ss[-1] and ss[1] == ss[0]*flag*ss[-2]:
  ans = ss
elif sw[0] == sw[-1] and sw[1] == sw[0]*flag*sw[-2]:
  ans = sw
elif ws[0] == ws[-1] and ws[1] == ws[0]*flag*ws[-2]:
  ans = ws
elif ww[0] == ww[-1] and ww[1] == ww[0]*flag*ww[-2]:
  ans = ww
if ans == []:
  print(-1)
else:
  ans = ans[:n]
  ans = ["S" if i == 1 else "W" for i in ans]
  print("".join(ans))

Solution (Python):
rev_ox = {"o":"x", "x":"o"}
rev_sw = {"S":"W", "W":"S"}

def get_next(sw_prev2,sw_prev1,ox_prev1):
        
    sw = sw_prev2
    if sw_prev1 == "W": ox_prev1 = rev_ox[ox_prev1]
    if ox_prev1 == "x": sw = rev_sw[sw]
    
    return sw

n = int(input())
ox = input()

for sw0,sw1 in [("S","S"),("S","W"),("W","S"),("W","W")]:
    ans = ""
    ans = sw0+sw1
    for i,oxi in enumerate(ox[1:]+ox[0],1):
        ans += get_next(ans[i-1],ans[i],oxi)
    
    if ans[0] == ans[-2] and ans[1] == ans[-1]:
        ans = ans[:-2]
        break
else:
    ans = -1

print(ans)

Solution (Python):
def get_next(sw_prev2,sw_prev1,ox_prev1):
    
    rev_ox = {"o":"x", "x":"o"}
    rev_sw = {"S":"W", "W":"S"}
    
    sw = sw_prev2
    if sw_prev1 == "W": ox_prev1 = rev_ox[ox_prev1]
    if ox_prev1 == "x": sw = rev_sw[sw]
    
    return sw

n = int(input())
ox = input()

ans = [None] * (n+2)
for sw0,sw1 in [("S","S"),("S","W"),("W","S"),("W","W")]:
     
    ans[0] = sw0
    ans[1] = sw1
    
    for i,oxi in enumerate(ox[1:]+ox[0],1):
        ans[i+1] = get_next(ans[i-1],ans[i],oxi)
    
    if ans[0] == ans[-2] and ans[1] == ans[-1]:
        break
else:
    ans = [-1]

print("".join(map(str,ans[:n])))

Solution (Python):
def get_next(sw_prev2,sw_prev1,ox_prev1):
    
    rev_ox = {"o":"x", "x":"o"}
    rev_sw = {"S":"W", "W":"S"}
    
    sw = sw_prev2
    if sw_prev1 == "W": ox_prev1 = rev_ox[ox_prev1]
    if ox_prev1 == "x": sw = rev_sw[sw]
    
    return sw

n = int(input())
ox = input()

for sw0,sw1 in [("S","S"),("S","W"),("W","S"),("W","W")]:
    ans = ""
    ans = sw0+sw1
    for i,oxi in enumerate(ox[1:]+ox[0],1):
        ans += get_next(ans[i-1],ans[i],oxi)
    
    if ans[0] == ans[-2] and ans[1] == ans[-1]:
        ans = ans[:-2]
        break
else:
    ans = -1

print(ans)

Solution (Python):
n=int(input())
s=input()
p1=["W","W"]
p2=["W","S"]
p3=["S","W"]
p4=["S","S"]
p=[p1,p2,p3,p4]
for i in range(4):
	for j in range(n-2):
		same=0
		if p[i][j+1]=="S" and s[j+1]=="o"\
		or p[i][j+1]=="W" and s[j+1]=="x":
			same=1
		if same and p[i][j]=="S" or not same and p[i][j]=="W":
			p[i].append("S")
		else:
			p[i].append("W")
	f=0
	same=0
	if p[i][-1]=="S" and s[-1]=="o"\
	or p[i][-1]=="W" and s[-1]=="x":
		same=1
	if same and p[i][-2]=="S" or not same and p[i][-2]=="W":
		if p[i][0]=="S":
			f=1
	else:
		if p[i][0]=="W":
			f=1
	if f==0:
		continue
	f=0
	same=0
	if p[i][0]=="S" and s[0]=="o"\
	or p[i][0]=="W" and s[0]=="x":
		same=1
	if same and p[i][-1]=="S" or not same and p[i][-1]=="W":
		if p[i][1]=="S":
			f=1
	else:
		if p[i][1]=="W":
			f=1
	if f:
		ans=""
		for x in p[i]:
			ans+=x
		print(ans)
		exit()
print(-1)

Solution (Python):
N = int(input())
S = input()

ans = [''] * N

def other(s):
  if s == 'S':
    return 'W'
  else:
    return 'S'

def calc(S):
  global ans
  for i, s in enumerate(S[1:], 1):
    if s == 'o':
      if ans[i] == 'S':
        ans[(i+1)%N] = ans[i-1]
      else:
        ans[(i+1)%N] = other(ans[i-1])
    else:
      if ans[i] == 'S':
        ans[(i+1)%N] = other(ans[i-1])
      else:
        ans[(i+1)%N] = ans[i-1]

if S[0] == 'o':
  ans[0] = 'S'
  ans[1] = 'S'
  calc(S)
  if (ans[0], ans[-1]) == ('S', 'S'):
    print(''.join(ans))
    quit()
  ans[0] = 'W'
  calc(S)
  if (ans[0], ans[-1]) == ('W', 'W'):
    print(''.join(ans))
    quit()
  ans[0] = 'S'
  ans[1] = 'W'
  calc(S)
  if (ans[0], ans[-1]) == ('S', 'W'):
    print(''.join(ans))
    quit()
  ans[0] = 'W'
  calc(S)
  if (ans[0], ans[-1]) == ('W', 'S'):
    print(''.join(ans))
    quit()
else:
  ans[0] = 'S'
  ans[1] = 'S'
  calc(S)
  if (ans[0], ans[-1]) == ('S', 'W'):
    print(''.join(ans))
    quit()
  ans[0] = 'W'
  calc(S)
  if (ans[0], ans[-1]) == ('W', 'S'):
    print(''.join(ans))
    quit()
  ans[0] = 'S'
  ans[1] = 'W'
  calc(S)
  if (ans[0], ans[-1]) == ('S', 'S'):
    print(''.join(ans))
    quit()
  ans[0] = 'W'
  calc(S)
  if (ans[0], ans[-1]) == ('W', 'W'):
    print(''.join(ans))
    quit()

print(-1)

Solution (Python):
N = int(input())
S = input()

ans = [''] * N

def other(s):
  if s == 'S':
    return 'W'
  else:
    return 'S'

def calc(S):
  global ans
  for i, s in enumerate(S):
    if s == 'o':
      if ans[i] == 'S':
        ans[(i+1)%N] = ans[i-1]
      else:
        ans[(i+1)%N] = other(ans[i-1])
    else:
      if ans[i] == 'S':
        ans[(i+1)%N] = other(ans[i-1])
      else:
        ans[(i+1)%N] = ans[i-1]

ans[-1] = 'S'
ans[0] = 'S'
calc(S)
if (ans[0], ans[-1]) == ('S', 'S'):
  print(''.join(ans))
  quit()

ans[-1] = 'S'
ans[0] = 'W'
calc(S)
if (ans[0], ans[-1]) == ('W', 'S'):
  print(''.join(ans))
  quit()

ans[-1] = 'W'
ans[0] = 'S'
calc(S)
if (ans[0], ans[-1]) == ('S', 'W'):
  print(''.join(ans))
  quit()

ans[-1] = 'W'
ans[0] = 'W'
calc(S)
if (ans[0], ans[-1]) == ('W', 'W'):
  print(''.join(ans))
  quit()

print(-1)

Solution (Python):
import sys
n = int(input())
s = input()

for ans in [["S", "S"], ["S", "W"], ["W", "S"], ["W", "W"]]:
    for i in range(n-1):
        if s[(i+1)] == "o":
            if ans[i+1] == "S":
                if ans[i] == "S":
                    ans.append("S")
                else:
                    ans.append("W")
            else:
                if ans[i] == "S":
                    ans.append("W")
                else:
                    ans.append("S")
        if s[(i+1)] == "x":
            if ans[i+1] == "S":
                if ans[i] == "S":
                    ans.append("W")
                else:
                    ans.append("S")
            else:
                if ans[i] == "S":
                    ans.append("S")
                else:
                    ans.append("W")

    if ans[0] == ans[-1]:
        ans.pop()
        flag = 0
        if s[0] == "o":
            if ans[0] == "S":
                if ans[-1] == ans[1]:
                    flag = 1
            else:
                if ans[-1] != ans[1]:
                    flag = 1
        else:
            if ans[0] == "W":
                if ans[-1] == ans[1]:
                    flag = 1
            else:
                if ans[-1] != ans[1]:
                    flag = 1
        if flag == 1:
            print("".join(ans))
            sys.exit()
print(-1)

Solution (Python):
N = int(input())
S = input()

for a in ["SS", "SW", "WS", "WW"]:
    x = list(a)
    for i in range(N - 2):
        if S[i + 1] == "o":
            if x[i + 1] == "S":
                x.append(x[i])
            else:
                
                if x[i] == "S":
                    x.append("W")
                else:
                    x.append("S")
        else:
            
            if x[i + 1] == "S":
                if x[i] == "S":
                    x.append("W")
                else:
                    x.append("S")
            else:
                x.append(x[i])

    
    mask_n = (x[-1] == "S") and ((S[-1] == "o" and x[-2] == x[0]) \
                                 or (S[-1] == "x" and x[-2] != x[0]))
    mask_n |= (x[-1] == "W") and ((S[-1] == "o" and x[-2] != x[0]) \
                                  or (S[-1] == "x" and x[-2] == x[0]))
    
    mask_1 = (x[0] == "S") and ((S[0] == "o" and x[-1] == x[1]) \
                                or (S[0] == "x" and x[-1] != x[1]))
    mask_1 |= (x[0] == "W") and ((S[0] == "o" and x[-1] != x[1]) \
                                 or (S[0] == "x" and x[-1] == x[1]))

    if mask_n and mask_1:
        print("".join(x))
        break
else:
    print(-1)

Solution (Python):
def d_menagerie():
    N = int(input())
    S = input()

    s = S + S[:2]  
    for ans in ('SS', 'SW', 'WS', 'WW'):  
        for i in range(1, N + 1):
            if (ans[-1] == 'S' and s[i] == 'o') or (ans[-1] == 'W' and s[i] == 'x'):
                
                
                ans += ans[-2]
            else:
                
                ans += ('S' if ans[-2] == 'W' else 'W')
        if ans[:2] == ans[N:]:
            
            return ans[:N]
    return '-1'  

print(d_menagerie())

Solution (Python):
N = int(input())
s = str(input())
A = ''

def majikayo():
    k = 0
    if A[0] == 'S' and s[0] == 'o':
        if A[-1] == 'S' and s[-1] == 'o':
            if A[1] == 'S' and A[-2] == 'S':
                k = 1
        elif A[-1] == 'S' and s[-1] == 'x':
            if A[1] == 'S' and A[-2] == 'W':
                k = 1
        elif A[-1] == 'W' and s[-1] == 'o':
            if A[1] == 'W' and A[-2] == 'W':
                k = 1
        elif A[-1] == 'W' and s[-1] == 'x':
            if A[1] == 'W' and A[-2] == 'S':
                k = 1
    elif A[0] == 'S' and s[0] == 'x':
        if A[-1] == 'S' and s[-1] == 'o':
            if A[1] == 'W' and A[-2] == 'S':
                k = 1
        elif A[-1] == 'S' and s[-1] == 'x':
            if A[1] == 'W' and A[-2] == 'W':
                k = 1
        elif A[-1] == 'W' and s[-1] == 'o':
            if A[1] == 'S' and A[-2] == 'W':
                k = 1
        elif A[-1] == 'W' and s[-1] == 'x':
            if A[1] == 'S' and A[-2] == 'S':
                k = 1
    elif A[0] == 'W' and s[0] == 'o':
        if A[-1] == 'S' and s[-1] == 'o':
            if A[1] == 'W' and A[-2] == 'W':
                k = 1
        elif A[-1] == 'S' and s[-1] == 'x':
            if A[1] == 'W' and A[-2] == 'S':
                k = 1
        elif A[-1] == 'W' and s[-1] == 'o':
            if A[1] == 'S' and A[-2] == 'S':
                k = 1
        elif A[-1] == 'W' and s[-1] == 'x':
            if A[1] == 'S' and A[-2] == 'W':
                k = 1
    elif A[0] == 'W' and s[0] == 'x':
        if A[-1] == 'S' and s[-1] == 'o':
            if A[1] == 'S' and A[-2] == 'W':
                k = 1
        elif A[-1] == 'S' and s[-1] == 'x':
            if A[1] == 'S' and A[-2] == 'S':
                k = 1
        elif A[-1] == 'W' and s[-1] == 'o':
            if A[1] == 'W' and A[-2] == 'S':
                k = 1
        elif A[-1] == 'W' and s[-1] == 'x':
            if A[1] == 'W' and A[-2] == 'W':
                k = 1
    if k == 1:
        return 1

A = 'SS'
for i in range(1,N-1):
    if s[i] == 'o' and A[i] == 'S':
        if A[i-1] == 'S':
            A += 'S'
        else:
            A += 'W'
    elif s[i] == 'o' and A[i] == 'W':
        if A[i-1] == 'S':
            A += 'W'
        else:
            A += 'S'
    elif s[i] == 'x' and A[i] == 'S':
        if A[i-1] == 'S':
            A += 'W'
        else:
            A += 'S'
    elif s[i] == 'x' and A[i] == 'W':
        if A[i-1] == 'S':
            A += 'S'
        else:
            A += 'W'
if majikayo() == 1:
    print(A)
else:
    A = 'SW'
    for i in range(1,N-1):
        if s[i] == 'o' and A[i] == 'S':
            if A[i-1] == 'S':
                A += 'S'
            else:
                A += 'W'
        elif s[i] == 'o' and A[i] == 'W':
            if A[i-1] == 'S':
                A += 'W'
            else:
                A += 'S'
        elif s[i] == 'x' and A[i] == 'S':
            if A[i-1] == 'S':
                A += 'W'
            else:
                A += 'S'
        elif s[i] == 'x' and A[i] == 'W':
            if A[i-1] == 'S':
                A += 'S'
            else:
                A += 'W'
    if majikayo() == 1:
        print(A)
    else:
        k = 0
        A = 'WS'
        for i in range(1,N-1):
            if s[i] == 'o' and A[i] == 'S':
                if A[i-1] == 'S':
                    A += 'S'
                else:
                    A += 'W'
            elif s[i] == 'o' and A[i] == 'W':
                if A[i-1] == 'S':
                    A += 'W'
                else:
                    A += 'S'
            elif s[i] == 'x' and A[i] == 'S':
                if A[i-1] == 'S':
                    A += 'W'
                else:
                    A += 'S'
            elif s[i] == 'x' and A[i] == 'W':
                if A[i-1] == 'S':
                    A += 'S'
                else:
                    A += 'W'
        majikayo()
        if majikayo() == 1:
            print(A)
        else:
            k = 0
            A = 'WW'
            for i in range(1,N-1):
                if s[i] == 'o' and A[i] == 'S':
                    if A[i-1] == 'S':
                        A += 'S'
                    else:
                        A += 'W'
                elif s[i] == 'o' and A[i] == 'W':
                    if A[i-1] == 'S':
                        A += 'W'
                    else:
                        A += 'S'
                elif s[i] == 'x' and A[i] == 'S':
                    if A[i-1] == 'S':
                        A += 'W'
                    else:
                        A += 'S'
                elif s[i] == 'x' and A[i] == 'W':
                    if A[i-1] == 'S':
                        A += 'S'
                    else:
                        A += 'W'
            if majikayo() == 1:
                print(A)
            else:
                print(-1)

Solution (Python):
N = int(input())
s = str(input())
A = ''

def majikayo():
    k = 0
    if A[0] == 'S' and s[0] == 'o':
        if A[1] == A[-1]:
            if A[-1] == 'S' and s[-1] == 'o':
                if A[0] == A[-2]:
                    k = 1
            elif A[-1] == 'S' and s[-1] == 'x':
                if A[0] != A[-2]:
                    k = 1
            elif A[-1] == 'W' and s[-1] == 'o':
                if A[0] != A[-2]:
                    k = 1
            elif A[-1] == 'W' and s[-1] == 'x':
                if A[0] == A[-2]:
                    k = 1
    elif A[0] == 'S' and s[0] == 'x':
        if A[1] != A[-1]:
            if A[-1] == 'S' and s[-1] == 'o':
                if A[0] == A[-2]:
                    k = 1
            elif A[-1] == 'S' and s[-1] == 'x':
                if A[0] != A[-2]:
                    k = 1
            elif A[-1] == 'W' and s[-1] == 'o':
                if A[0] != A[-2]:
                    k = 1
            elif A[-1] == 'W' and s[-1] == 'x':
                if A[0] == A[-2]:
                    k = 1
    elif A[0] == 'W' and s[0] == 'o':
        if A[1] != A[-1]:
            if A[-1] == 'S' and s[-1] == 'o':
                if A[0] == A[-2]:
                    k = 1
            elif A[-1] == 'S' and s[-1] == 'x':
                if A[0] != A[-2]:
                    k = 1
            elif A[-1] == 'W' and s[-1] == 'o':
                if A[0] != A[-2]:
                    k = 1
            elif A[-1] == 'W' and s[-1] == 'x':
                if A[0] == A[-2]:
                    k = 1
    elif A[0] == 'W' and s[0] == 'x':
        if A[1] == A[-1]:
            if A[-1] == 'S' and s[-1] == 'o':
                if A[0] == A[-2]:
                    k = 1
            elif A[-1] == 'S' and s[-1] == 'x':
                if A[0] != A[-2]:
                    k = 1
            elif A[-1] == 'W' and s[-1] == 'o':
                if A[0] != A[-2]:
                    k = 1
            elif A[-1] == 'W' and s[-1] == 'x':
                if A[0] == A[-2]:
                    k = 1
    if k == 1:
        return 1

A = 'SS'
for i in range(1,N-1):
    if s[i] == 'o' and A[i] == 'S':
        if A[i-1] == 'S':
            A += 'S'
        else:
            A += 'W'
    elif s[i] == 'o' and A[i] == 'W':
        if A[i-1] == 'S':
            A += 'W'
        else:
            A += 'S'
    elif s[i] == 'x' and A[i] == 'S':
        if A[i-1] == 'S':
            A += 'W'
        else:
            A += 'S'
    elif s[i] == 'x' and A[i] == 'W':
        if A[i-1] == 'S':
            A += 'S'
        else:
            A += 'W'
if majikayo() == 1:
    print(A)
else:
    A = 'SW'
    for i in range(1,N-1):
        if s[i] == 'o' and A[i] == 'S':
            if A[i-1] == 'S':
                A += 'S'
            else:
                A += 'W'
        elif s[i] == 'o' and A[i] == 'W':
            if A[i-1] == 'S':
                A += 'W'
            else:
                A += 'S'
        elif s[i] == 'x' and A[i] == 'S':
            if A[i-1] == 'S':
                A += 'W'
            else:
                A += 'S'
        elif s[i] == 'x' and A[i] == 'W':
            if A[i-1] == 'S':
                A += 'S'
            else:
                A += 'W'
    if majikayo() == 1:
        print(A)
    else:
        A = 'WS'
        for i in range(1,N-1):
            if s[i] == 'o' and A[i] == 'S':
                if A[i-1] == 'S':
                    A += 'S'
                else:
                    A += 'W'
            elif s[i] == 'o' and A[i] == 'W':
                if A[i-1] == 'S':
                    A += 'W'
                else:
                    A += 'S'
            elif s[i] == 'x' and A[i] == 'S':
                if A[i-1] == 'S':
                    A += 'W'
                else:
                    A += 'S'
            elif s[i] == 'x' and A[i] == 'W':
                if A[i-1] == 'S':
                    A += 'S'
                else:
                    A += 'W'
        if majikayo() == 1:
            print(A)
        else:
            A = 'WW'
            for i in range(1,N-1):
                if s[i] == 'o' and A[i] == 'S':
                    if A[i-1] == 'S':
                        A += 'S'
                    else:
                        A += 'W'
                elif s[i] == 'o' and A[i] == 'W':
                    if A[i-1] == 'S':
                        A += 'W'
                    else:
                        A += 'S'
                elif s[i] == 'x' and A[i] == 'S':
                    if A[i-1] == 'S':
                        A += 'W'
                    else:
                        A += 'S'
                elif s[i] == 'x' and A[i] == 'W':
                    if A[i-1] == 'S':
                        A += 'S'
                    else:
                        A += 'W'
            if majikayo() == 1:
                print(A)
            else:
                print(-1)