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):
from itertools import product
N = int(input())
S = input()
S += S[0]


def isOK(x, y):
    WS = [-1] * (N + 2)
    WS[0] = x
    WS[1] = y
    for i in range(1, N + 1):
        if S[i] == "o":
            WS[i + 1] = WS[i - 1] if WS[i] else 1 - WS[i - 1]
        else:
            WS[i + 1] = 1 - WS[i - 1] if WS[i] else WS[i - 1]
    if WS[0] == WS[-2] and WS[1] == WS[-1]:
        return WS[:-2]
    else:
        return []


for x, y in product(range(2), repeat=2):
    ws = isOK(x, y)
    if len(ws) > 0:
        break

if len(ws) == 0:
    ans = -1
else:
    ans = ""
    for x in ws:
        if x:
            ans += "S"
        else:
            ans += "W"

print(ans)

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

cnt = 0
while cnt < 4:
    L = [0]*N
    if cnt == 0:
        L[-1] = "S"
        L[-2] = "S"
    elif cnt == 1:
        L[-1] = "S"
        L[-2] = "W"
    elif cnt == 2:
        L[-1] = "W"
        L[-2] = "S"
    else:
        L[-1] = "W"
        L[-2] = "W"

    for j in range(N-2, -1, -1):
        if L[j] == "S" and S[j] == "o":
            L[j-1] = L[j+1]
        elif L[j] == "S":
            if L[j+1] == "S":
                L[j-1] = "W"
            else:
                L[j-1] = "S"
        elif L[j] == "W" and S[j] == "o":
            if L[j+1] == "S":
                L[j-1] = "W"
            else:
                L[j-1] = "S"
        else:
            L[j-1] = L[j+1]
    if cnt <= 1 and L[-1] == "S" and S[-1] == "o":
        if L[-2] == L[0]:
            break
    elif cnt <= 1 and L[-1] == "S" and S[-1] == "x":
        if L[-2] != L[0]:
            break
    elif cnt >= 2 and L[-1] == "W" and S[-1] == "o":
        if L[-2] != L[0]:
            break
    elif cnt >= 2 and L[-1] == "W" and S[-1] == "x":
        if L[-2] == L[0]:
            break
    cnt += 1

if cnt == 4:
    print(-1)
else:
    print("".join(L))

Solution (Python):
def main():
    N = int(input())
    S = input()
    dsw = tuple([("S", "S"), ("S", "W"), ("W", "S"), ("W", "W")])
    for d1, d2 in dsw:
        cur = d1+d2
        for s in S[1:N-1]:
            if cur[-1] == "S":
                if s == "o":
                    cur += cur[-2]
                else:
                    cur += ("W" if cur[-2] == "S" else "S")
            else:
                if s == "o":
                    cur += ("W" if cur[-2] == "S" else "S")
                else:
                    cur += cur[-2]
        flag = False
        if cur[-1] == "S":
            if S[-1] == "o":
                flag = (cur[-2] == cur[0])
            else:
                flag = (cur[-2] != cur[0])
        else:
            if S[-1] == "o":
                flag = (cur[-2] != cur[0])
            else:
                flag = (cur[-2] == cur[0])
        if flag:
            if cur[0] == "S":
                if S[0] == "o":
                    flag = (cur[-1] == cur[1])
                else:
                    flag = (cur[-1] != cur[1])
            else:
                if S[0] == "o":
                    flag = (cur[-1] != cur[1])
                else:
                    flag = (cur[-1] == cur[1])
        if flag:
            return print(cur)

    print(-1)


if __name__ == '__main__':
    main()

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    S=ST()
    ans = [0]*N 
    for mask in range(4):
        ans[0] = bool(mask&1)
        ans[1] = bool(mask&2)
        for i in range(2,N):
            if (S[i-1]=="o") ^ ans[i-1]:
                ans[i] = ans[i-2]
            else:
                ans[i] = ans[i-2] ^ True
        ok = True
        for i in range(N):
            if ((S[i] == "o") ^ ans[i]) ^ (ans[(i+1)%N] == ans[i-1]):
                ok = False
        if ok:
            print(*["W" if a else "S" for a in ans ],sep="")
            return 
    print(-1)
if __name__ == '__main__':
    main()

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

def judge(a1,an):
    A=[-1]*N
    A[0]=a1
    A[N-1]=an
    A[1]=A[N-1]^A[0]^(1 if s[0]=='o' else 0)
    for i in range(1,N-2):
        A[i+1]=A[i-1]^A[i]^(1 if s[i]=='o' else 0)
    jn=A[N-3]^A[N-2]^(1 if s[N-2]=='o' else 0)
    j1=A[N-2]^jn^(1 if s[N-1]=='o' else 0)
    if j1==a1 and jn==an: return A
    return None

for a1 in range(2):
    for an in range(2):
        r = judge(a1,an)
        if r!=None:
            print(''.join([('S' if a==1 else 'W') for a in r]))
            exit()
print(-1)

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

for a,b in ['SS','SW','WS','WW']:
    tmp = a+b
    for c in S:
        if (c=='x') ^ (tmp[-1]=='W'):
            tmp += ('W' if tmp[-2]=='S' else 'S')
        else:
            tmp += tmp[-2]
    
    if tmp[:2] == tmp[-2:]:
        print(tmp[1:-1])
        exit()
print(-1)

Solution (Python):

import numpy as np
import sys
sys.setrecursionlimit(100000)


def acinput():
    return list(map(int, input().split(" ")))


directions = np.array([[1, 0], [0, 1], [-1, 0], [0, -1]])
directions = list(map(np.array, directions))

mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact


def serch(x, count):
    

    for d in directions:
        nx = d+x
        
        if np.all(0 <= nx) and np.all(nx < (H, W)):
            if field[nx[0]][nx[1]] == "E":
                count += 1
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)
                continue
            if field[nx[0]][nx[1]] == "
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)

    return count


N = int(input())
s = list(input())


def chk(init_tf):
    tf = [-1]*(N)

    tf[0:2] = init_tf
    for i in range(2, N):
        if tf[i-1] == 1:
            if s[i-1] == "o":
                
                tf[i] = tf[i-2]
            else:
                tf[i] = (tf[i-2]+1) % 2

        if tf[i-1] == 0:
            if s[i-1] == "o":
                tf[i] = (tf[i-2]+1) % 2
            else:
                tf[i] = tf[i-2]
    """ 
    print(tf)
    print(s)
     """

    for i in range(N):
        
        r=(i+1)%(N)
     
        if tf[i] == 1:
            if s[i]=="o":
                if tf[i-1] !=tf[r]:
                    return False       
            else:
                if tf[i-1] == tf[r]:
                    return False

        elif tf[i] == 0:
            if s[i] == "x":
                if tf[i-1] != tf[r]:
                    return False
            else:
                if tf[i-1] == tf[r]:
                    return False

    return ["S" if x == 1 else "W" for x in tf]


for i in range(2):
    for j in range(2):
        res=chk((i,j))
        if res:
            print("".join(res))
            sys.exit()

print(-1)

Solution (Python):
n=int(input())
s=list(input())
ans=[[0]*n for i in range(4)]
ans[1][1]=1
ans[2][0]=1
ans[3][0]=ans[3][1]=1
idx=-1
for i in range(4):
  for j in range(1,n-1):
    if s[j]=='o' and ans[i][j]==1 and ans[i][j-1]==1:
      ans[i][j+1]=1
    elif s[j]=='o' and ans[i][j]==1 and ans[i][j-1]==0:
      ans[i][j+1]=0
    elif s[j]=='o' and ans[i][j]==0 and ans[i][j-1]==1:
      ans[i][j+1]=0
    elif s[j]=='o' and ans[i][j]==0 and ans[i][j-1]==0:
      ans[i][j+1]=1
    elif s[j]=='x' and ans[i][j]==1 and ans[i][j-1]==1:
      ans[i][j+1]=0
    elif s[j]=='x' and ans[i][j]==1 and ans[i][j-1]==0:
      ans[i][j+1]=1
    elif s[j]=='x' and ans[i][j]==0 and ans[i][j-1]==1:
      ans[i][j+1]=1
    else:
      ans[i][j+1]=0
  flag1=False
  flag2=False
  if ans[i][n-1]==1 and ans[i][0]==ans[i][n-2] and s[n-1]=='o':
    flag1=True
  elif ans[i][n-1]==1 and ans[i][0]!=ans[i][n-2] and s[n-1]=='x':
    flag1=True
  elif ans[i][n-1]==0 and ans[i][0]==ans[i][n-2] and s[n-1]=='x':
    flag1=True
  elif ans[i][n-1]==0 and ans[i][0]!=ans[i][n-2] and s[n-1]=='o':
    flag1=True
  if ans[i][0]==1 and ans[i][n-1]==ans[i][1] and s[0]=='o':
    flag2=True
  elif ans[i][0]==0 and ans[i][n-1]==ans[i][1] and s[0]=='x':
    flag2=True
  elif ans[i][0]==1 and ans[i][n-1]!=ans[i][1] and s[0]=='x':
    flag2=True
  elif ans[i][0]==0 and ans[i][n-1]!=ans[i][1] and s[0]=='o':
    flag2=True
  if flag1 and flag2:
    idx=i
    break
if idx==-1:
  print(-1)
  exit()
t=[]
for i in range(n):
  if ans[idx][i]==1:
    t.append('S')
  else:
    t.append('W')
print(''.join(t))

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

for b, c in ["SS", "SW", "WS", "WW"]:

    fb, fc = b, c
    rs = [""]*N
    for i in range(N):
        cc = c
        if S[i] == 'o':
            if c == "S":
                c = "S" if b == "S" else "W"
            else:
                c = "W" if b == "S" else "S"
        else:
            if c == "S":
                c = "W" if b == "S" else "S"
            else:
                c = "S" if b == "S" else "W"
        b = cc
        if i != N-1:
            rs[i+1] = c
        else:
            rs[0] = c
    if rs[0] == fc and rs[-1] == fb:
        print("".join(rs))
        break
else:
    print(-1)

Solution (Python):
import sys
import itertools
input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def f(S, init):
    F = [init[0], init[1]]
    for i, s in enumerate(S):
        if i == 0:
            continue
        d = 1 if s == "o" else -1
        F.append(F[i - 1] * F[i] * d)
    
    if F[0] != F[-1]:
        return None
    
    d = 1 if S[0] == "o" else -1
    d *= F[0]
    N = len(S)
    if F[-2] * F[1] == d:
        
        return F[:N]
    else:
        return None


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

    for init in [(1, 1), (-1, 1), (1, -1), (-1, -1)]:
        F = f(S, init)
        if F is not None:
            F = map(lambda v: "S" if v == 1 else "W", F)
            print("".join(F))
            return 
    
    print(-1)


if __name__ == "__main__":
    main()

Solution (Python):
from collections import *
from itertools import *
import copy
from heapq import *

N=int(input())
S=input()
def check(data):
    for i in range(N):
        if data[i]=="S" and S[i]=="o" or data[i]=="W" and S[i]=="x":
            if data[i-1]==data[(i+1) if i+1<N else (i+1-N)]:
                pass
            else:
                return(0)
        else:
            if data[i-1]!=data[(i+1) if i+1<N else (i+1-N)]:
                pass
            else:
                return(0)
    return(1)


for s1 in ["S","W"]:
    for s2 in ["S","W"]:
        data=[0 for i in range(N)]
        data[0],data[1]=s1,s2

        for i in range(2,N):
            if data[i-1]=="S" and S[i-1]=="o" or data[i-1]=="W" and S[i-1]=="x":
                data[i]=data[i-2]
            else:
                data[i]="S" if data[i-2]=="W" else "W"

        if check(data):
            print("".join(list(map(str,data))))
            exit()

print(-1)

Solution (Python):
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True 
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def right(aim,ai,si):
    if ai==0:
        return aim if si=='o' else (1-aim)
    else:
        return (1-aim) if si=='o' else aim

n = inn()
s = ins()
for a0 in [0,1]:
    for a1 in [0,1]:
        a = [-1]*n
        a[0] = a0
        a[1] = a1
        for i in range(1,n-1):
            a[i+1] = right(a[i-1],a[i],s[i])
        if right(a[n-2],a[n-1],s[n-1])==a[0] and \
           right(a[n-1],a[0],s[0])==a[1] :
           for j in range(n):
               printn('S' if a[j]==0 else 'W')
           print('')
           exit()
print(-1)

Solution (Python):
def examC():
    N, M = LI()
    if N-M//2>=0:
        ans = M//2
    else:
        ans = N + (M-N*2)//4
    print(ans)
    return

def examD():
    N = I()
    S = SI()
    for i1,i2 in [[0,0],[0,1],[1,0],[1,1]]:
        flag = True
        sheep = [1]*N
        sheep[0] = i1
        sheep[1] = i2
        for j in range(1,N-1):
            if S[j]=="o":
                cur = 1
            else:
                cur = 0
            sheep[j+1] = (sheep[j]^cur)^sheep[j-1]
        if S[-1] == "o":
            cur = 1
        else:
            cur = 0
        if sheep[0]!=(sheep[-1] ^ cur) ^ sheep[-2]:
            flag = False
        if S[0] == "o":
            cur = 1
        else:
            cur = 0
        if sheep[1]!=(sheep[0] ^ cur) ^ sheep[-1]:
            flag = False
        if flag:
            ans = ""
            for i in sheep:
                if i==1:
                    ans += "S"
                else:
                    ans += "W"
            print(ans)
            return
    print(-1)
    return

def examE():
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examD()

"""

"""

Solution (Python):
N = int(input())
S = input()
S = S[-1] + S + S[0]


isOK = False
for x, y in [(1, 1), (1, 0), (0, 1), (0, 0)]:
    A = [-1] * len(S)
    A[0] = x
    A[1] = y
    for i in range(1, len(S)-1):
        if A[i]:  
            A[i + 1] = A[i - 1] if S[i] == "o" else 1 - A[i - 1]
        else:  
            A[i + 1] = A[i - 1] if S[i] == "x" else 1 - A[i - 1]

    if A[0] == A[-2] and A[1] == A[-1]:
        isOK = True
        break

if isOK:
    ans = ["S" if i else "W" for i in A[1:-1]]
    ans = "".join(ans)
else:
    ans = -1

print(ans)

Solution (Python):
def f(x,y,z):
    if x=="S" and y=="o":
        return z
    if x=="S" and y=="x":
        return g(z)
    if x=="W" and y=="o":
        return g(z)
    if x=="W" and y=="x":
        return z
def g(x):
    if x=="S":
        return "W"
    if x=="W":
        return "S"
def check(x,y):
    t[0]=x
    t[1]=y
    for j in range(1,N-1):
        t[j+1] = f(t[j],s[j],t[j-1])
    x1 = f(t[N-1],s[N-1],t[N-2])
    y1 = f(x1,s[0],t[N-1])
    if x==x1 and y==y1:
        return True
    else:
        return False
N = int(input())
s = input().strip()
t = [0 for _ in range(N)]
if check("S","S"):
    print("".join(t))
elif check("S","W"):
    print("".join(t))
elif check("W","S"):
    print("".join(t))
elif check("W","W"):
    print("".join(t))
else:
    print(-1)

Solution (Python):
n = int(input())
s = [0 if i=="o" else 1 for i in input()]
for i in range(4):
  dp = [0]*n
  dp[0], dp[1] = divmod(i, 2)
  for i in range(2, n):
    dp[i] = dp[i-2]^dp[i-1]^s[i-1]
  if dp[-2]^dp[-1]^s[-1] == dp[0] and dp[-1]^dp[0]^s[0] == dp[1]:
    A = ["S" if i==0 else "W" for i in dp]
    print(*A, sep="")
    break
else:
  print(-1)

Solution (Python):

import sys
n = int(input())
s = input()

L = ["SS","SW","WS","WW"]
l= len(s)



for t in L:
    tmp = t
    for i in range(l):
        if (s[i]=="x") ^ (tmp[-1] == "W"):
            if tmp[-2]=="S":
                tmp+= "W"
            else:
                tmp += "S"
            
        else:
            tmp += tmp[-2]
    if tmp[:2]==tmp[-2:]:
        print(tmp[1:-1])
        sys.exit()
print(-1)

Solution (Python):
def check(b0, b1):
    is_sheep[0] = b0
    is_sheep[1] = b1
    
    for i in range(1, N):
        if s[i]=='o':
            if is_sheep[i]:
                is_sheep[(i+1)%N] = is_sheep[i-1]
            else:
                is_sheep[(i+1)%N] = not is_sheep[i-1]
        else:
            if is_sheep[i]:
                is_sheep[(i+1)%N] = not is_sheep[i-1]
            else:
                is_sheep[(i+1)%N] = is_sheep[i-1]
    
    if b0==is_sheep[0]:
        if s[0]=='o':
            if b0:
                return is_sheep[N-1]==is_sheep[1]
            else:
                return is_sheep[N-1]!=is_sheep[1]
        else:
            if b0:
                return is_sheep[N-1]!=is_sheep[1]
            else:
                return is_sheep[N-1]==is_sheep[1]
    else:
        return False

N = int(input())
s = input()
is_sheep = [False]*N

for b0, b1 in [(False, False), (False, True), (True, False), (True, True)]:
    if check(b0, b1):
        ans = ['S' if is_sheep[i] else 'W' for i in range(N)]
        print(''.join(ans))
        break
else:
    print(-1)

Solution (Python):
n = int(input())
s = list(input())
st = [["S","S"],["S","W"],["W","W"],["W","S"]]
key = "F"
for i in st:
    ans = i
    a0,a1 = i
    for j in range(1,n):
        
        if s[j] == "o":
            if a1 == "S":
                if a0 == "S":
                    ans.append("S")
                    a0 = "S"
                    a1 = "S"
                else:
                    ans.append("W")
                    a0 = "S"
                    a1 = "W"
            else:
                if a0 == "S":
                    ans.append("W")
                    a0 = "W"
                    a1 = "W"
                else:
                    ans.append("S")
                    a0 = "W"
                    a1 = "S"
        else:
            if a1 == "W":
                if a0 == "S":
                    ans.append("S")
                    a0 = "W"
                    a1 = "S"
                else:
                    ans.append("W")
                    a0 = "W"
                    a1 = "W"
            else:
                if a0 == "S":
                    ans.append("W")
                    a0 = "S"
                    a1 = "W"
                else:
                    ans.append("S")
                    a0 = "S"
                    a1 = "S"
    if ans[0] == ans[n]:
        a0 = ans[n-1]
        a1 = ans[n]
        if s[0] == "o":
            if a1 == "S":
                if a0 == "S":
                    ans.append("S")
                    a0 = "S"
                    a1 = "S"
                else:
                    ans.append("W")
                    a0 = "S"
                    a1 = "W"
            else:
                if a0 == "S":
                    ans.append("W")
                    a0 = "W"
                    a1 = "W"
                else:
                    ans.append("S")
                    a0 = "W"
                    a1 = "S"
        else:
            if a1 == "W":
                if a0 == "S":
                    ans.append("S")
                    a0 = "W"
                    a1 = "S"
                else:
                    ans.append("W")
                    a0 = "W"
                    a1 = "W"
            else:
                if a0 == "S":
                    ans.append("W")
                    a0 = "S"
                    a1 = "W"
                else:
                    ans.append("S")
                    a0 = "S"
                    a1 = "S"
        if ans[1] == ans[n+1]:
            key = "T"
            break
if key == "T":
    for i in range(n):
        print(ans[i],end="")
else:
    print(-1)

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return "".join(map(str,x))
def max2(x): 
    return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()

a = list(input())[:-1]

pata = ["S","W"]

for fi in pata:
    for se in pata:
        aaa = [fi,se]
        for i in range(1,n-1):
            if aaa[-1] == "S":
                if a[i] == "o":
                    aaa.append(aaa[-2])
                else:
                    if aaa[-2] == "S":
                        aaa.append("W")
                    else:
                        aaa.append("S")
            else:
                if a[i] == "o":
                    if aaa[-2] == "S":
                        aaa.append("W")
                    else:
                        aaa.append("S")
                    
                else:
                    aaa.append(aaa[-2])
        flag = True

        if aaa[-1] == "S":
            if a[-1] == "o":
                if aaa[-2] != aaa[0]:
                    flag = False
            else:
                if aaa[-2] == aaa[0]:
                    flag = False
        else:
            if a[-1] == "x":
                if aaa[-2] != aaa[0]:
                    flag = False
            else:
                if aaa[-2] == aaa[0]:
                    flag = False
        if aaa[0] == "S":
            if a[0] == "o":
                if aaa[-1] != aaa[1]:
                    flag = False
            else:
                if aaa[-1] == aaa[1]:
                    flag = False
        else:
            if a[0] == "x":
                if aaa[-1] != aaa[1]:
                    flag = False
            else:
                if aaa[-1] == aaa[1]:
                    flag = False
        if flag:
            print(jo(aaa))
            exit()
print(-1)
exit()

Solution (Python):
N=int(input())
s=list(input())
for i in range(2**2):
  sw=[1,1]
  ans=[1]*(N+1)
  for j in range(2):
    if (i>>j)%2==1:
      sw[j]=0
      ans[j]=0
  for j in range(1,N):
    if sw[1]== 1:
      if s[j]=="o":
        sw[0],sw[1]=sw[1],sw[0]
      else:
        sw[0],sw[1]=sw[1],(sw[0])^1
    else:
      if s[j]=="o":
        sw[0],sw[1]=sw[1],(sw[0])^1
      else:
        sw[0],sw[1]=sw[1],sw[0]
    ans[j+1]=sw[1]
  
  if ans[0]==ans[N]:
    if ans[0]==1:
      if s[0]=="o":
        if ans[N-1]!=ans[1]:
          continue
      else:
        if ans[N-1]==ans[1]:
          continue
    else:
      if s[0]=="o":
        if ans[N-1]==ans[1]:
          continue
      else:
        if ans[N-1]!=ans[1]:
          continue
    for i in range(N):
      if ans[i]==1:
        ans[i]="S"
      else:
        ans[i]="W"
    print("".join(ans[:N]))
    exit(0)
  else:
    continue
print(-1)

Solution (Python):
import sys

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  

N = ri()
S = rs()
d = {'S': 'W', 'W': 'S'}
for x in ['SS', 'SW', 'WS', 'WW']:
    animals = x
    for i in range(N):
        if S[i] == 'o':
            if animals[i+1] == 'S':
                animals += animals[i]
            else:
                animals += d[animals[i]]
        else:
            if animals[i+1] == 'S':
                animals += d[animals[i]]
            else:
                animals += animals[i]
    if animals[0:2] == animals[-2:]:
        print(animals[1:-1])
        exit()

print(-1)

Solution (Python):
def main():
  N = int(input())
  s = input()
  L = [["S","S"],["S","W"],["W","W"],["W","S"]]
  for i in range(1,N):
    for j in range(4):
      if s[i] == "o":
        if L[j][-1] == "S":
          L[j].append(L[j][-2])
        else:
          if L[j][-2] == "S":
            L[j].append("W")
          else:
            L[j].append("S")
      else:
        if L[j][-1] == "S":
          if L[j][-2] == "S":
            L[j].append("W")
          else:
            L[j].append("S")
        else:
          L[j].append(L[j][-2])
  for i in range(4):
    flg = False
    if L[i][0] != L[i][-1]:
      continue
    if s[0] == "o":
      if L[i][-1] == "S" and L[i][1] == L[i][-2]:
        flg = True
      elif L[i][-1] == "W" and L[i][1] != L[i][-2]:
        flg = True
    else:
      if L[i][-1] == "W" and L[i][1] == L[i][-2]:
        flg = True
      elif L[i][-1] == "S" and L[i][1] != L[i][-2]:
        flg = True
    if flg:
      print(*L[i][:-1],sep="")
      exit()
  print(-1)
main()

Solution (Python):
n=int(input())
w1=list(input())
s="S"
w="W"
o="o"
x="x"
l=[[s,s],[s,w],[w,w],[w,s]]
for j in range(4):
    for i in range(1,n):
        if w1[i]==o:
            if l[j][-1]==s:
                if l[j][-2]==s:
                    l[j].append(s)
                else:
                    l[j].append(w)
            else:
                if l[j][-2]==s:
                    l[j].append(w)
                else:
                    l[j].append(s)
        else:
            if l[j][-1]==s:
                if l[j][-2]==s:
                    l[j].append(w)
                else:
                    l[j].append(s)
            else:
                if l[j][-2]==s:
                    l[j].append(s)
                else:
                    l[j].append(w)
b=False
for i in range(4):
  if l[i][0]==l[i][-1] and not b:
    del l[i][-1]
    if l[i][0]==s:
      if (l[i][1]==l[i][-1] and w1[0]==o) or (l[i][1]!=l[i][-1] and w1[0]==x):
        answer=l[i]
        b=True
        break
    else:
      if (l[i][1]!=l[i][-1] and w1[0]==o) or (l[i][1]==l[i][-1] and w1[0]==x):
        answer=l[i]
        b=True
        break
if not b:
    print(-1)
else:
    print("".join(answer))

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

for a0,a1 in [[1,1],[1,-1],[-1,1],[-1,-1]]:
  ans=[0]*N
  ans[0],ans[1]=a0,a1
  for i in range(2,N):
    if S[i-1]=="o":
      ans[i]=ans[i-2]*ans[i-1]
    else:
      ans[i]=-ans[i-2]*ans[i-1]

  if S[N-1]=="o":
    if ans[0]==ans[N-2]*ans[N-1]:
      if S[0]=="o":
        if ans[1]==ans[N-1]*ans[0]:
          print("".join(map(lambda x:"S" if x==1 else "W",ans)))
          exit()
      else:
        if ans[1]==-ans[N-1]*ans[0]:
          print("".join(map(lambda x:"S" if x==1 else "W",ans)))
          exit()
  else:
    if ans[0]==-ans[N-2]*ans[N-1]:
      if S[0]=="o":
        if ans[1]==ans[N-1]*ans[0]:
          print("".join(map(lambda x:"S" if x==1 else "W",ans)))
          exit()
      else:
        if ans[1]==-ans[N-1]*ans[0]:
          print("".join(map(lambda x:"S" if x==1 else "W",ans)))
          exit()

print(-1)

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

isF = [False for i in range(N)]
isT = [False for i in range(N)]

def isSatisfied():
    for i in range(2, N+2):
        different = (S[(i - 1) % N] == "x" and isT[(i - 1) % N]) or (S[(i - 1) % N] == "o" and isF[(i - 1) % N])
        if different:
            isF[i % N] |= not isF[(i-2) % N]
            isT[i % N] |= not isT[(i-2) % N]
        else:
            isF[i % N] |= isF[(i-2) % N]
            isT[i % N] |= isT[(i-2) % N]
    for j in range(2, N+2):
        i = 1-i
        different = (S[(i + 1) % N] == "x" and isT[(i + 1) % N]) or (S[(i + 1) % N] == "o" and isF[(i + 1) % N])
        if different:
            isF[i % N] |= not isF[(i+2) % N]
            isT[i % N] |= not isT[(i+2) % N]
        else:
            isF[i % N] |= isF[(i+2) % N]
            isT[ i% N] |= isT[(i+2) % N]
    for i in range(N):
        if isF[i] and isT[i]: return False
    return True

for a in [False, True]:
    for b in [False, True]:
        isF = [False for i in range(N)]
        isT = [False for i in range(N)]
        isF[0] = a
        isT[0] = not a
        isF[1] = b
        isT[1] =  not b
        if isSatisfied():
            print("".join(["S" if isT[i] else "W" for i in range(N)]))
            quit()
print(-1)