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



Sample input:
6
ooxoox


Sample output:
SSSWWS

Submission status: Wrong Answer

Solution code:
"""
sheep oXo xXx ⇨ True
wolf  oXx xXo ⇨ True 
２点決める

s[i] == "o" and a[i] == "W"  a[i+1] != a[i-1]
s[i] == "o" and a[i] == "S"  a[i+1] == a[i-1]
s[i] == "x" and a[i] == "W"  a[i+1] == a[i-1]
s[i] == "x" and a[i] == "S"  a[i+1] != a[i-1]
"""
n = int(input())
s = input()
# S -> 0, W -> 1
ds = [(0,0),(0,1),(1,0),(1,1)]

for d0,d1 in ds:
    a = [d0,d1]
    for i in range(1,n-1):
        if s[i] == "o" and a[i] == 0:
            a.append(a[i-1])
        elif s[i] == "x" and a[i] == 0:
            a.append(a[i-1]^1)
        elif s[i] == "o" and a[i] == 1:
            a.append(a[i-1]^1)
        else:
            a.append(a[i-1])
    # 帳尻があっているかどうか
    X = ["S","W"]
    # print(a)
    if a[0] == 0 and s[0] == "x":
        if a[1] != a[-1]:
            a = "".join([X[i] for i in a])
            print(a)
            exit()
    if a[0] == 0 and s[0] == "o":
        if a[1] == a[-1]:
            a = "".join([X[i] for i in a])
            print(a)
            exit()
    if a[0] == 1 and s[0] == "x":
        if a[1] == a[-1]:
            a = "".join([X[i] for i in a])
            print(a)
            exit()
    if a[-0] == 1 and s[0] == "o":
        if a[1] != a[-1]:
            a = "".join([X[i] for i in a])
            print(a)
            exit()
print(-1)

Submission status: Wrong Answer

Solution code:
"""
sheep oXo xXx ⇨ True
wolf  oXx xXo ⇨ True 
２点決める

s[i] == "o" and a[i] == "W"  a[i+1] != a[i-1]
s[i] == "o" and a[i] == "S"  a[i+1] == a[i-1]
s[i] == "x" and a[i] == "W"  a[i+1] == a[i-1]
s[i] == "x" and a[i] == "S"  a[i+1] != a[i-1]
"""
n = int(input())
s = input()
# S -> 0, W -> 1
ds = [(0,0),(0,1),(1,0),(1,1)]

for d0,d1 in ds:
    a = [d0,d1]
    for i in range(1,n):
        if s[i] == "o" and a[i] == 0:
            a.append(a[i-1])
        elif s[i] == "x" and a[i] == 0:
            a.append(a[i-1]^1)
        elif s[i] == "o" and a[i] == 1:
            a.append(a[i-1]^1)
        else:
            a.append(a[i-1])
    # 帳尻があっているかどうか
    X = ["S","W"]
    # print(a)
    if a[-1] == a[0]:
        x = "".join([X[i] for i in a[:-1]])
        print(x)
        exit()
print(-1)

Submission status: Wrong Answer

Solution code:
"""
sheep oXo xXx ⇨ True
wolf  oXx xXo ⇨ True 
２点決める

s[i] == "o" and a[i] == "W"  a[i+1] != a[i-1]
s[i] == "o" and a[i] == "S"  a[i+1] == a[i-1]
s[i] == "x" and a[i] == "W"  a[i+1] == a[i-1]
s[i] == "x" and a[i] == "S"  a[i+1] != a[i-1]
"""
n = int(input())
s = input()
# S -> 0, W -> 1
ds = [(0,0),(0,1),(1,0),(1,1)]

for d0,d1 in ds:
    a = [d0,d1]
    for i in range(1,n-1):
        if s[i] == "o" and a[i] == 0:
            a.append(a[i-1])
        elif s[i] == "x" and a[i] == 0:
            a.append(a[i-1]^1)
        elif s[i] == "o" and a[i] == 1:
            a.append(a[i-1]^1)
        else:
            a.append(a[i-1])
    # 帳尻があっているかどうか
    X = ["S","W"]
    # print(a)
    if a[0] == 0 and s[0] == "x":
        if a[1] != a[-1]:
            x = "".join([X[i] for i in a])
            print(a)
            exit()
    if a[0] == 0 and s[0] == "o":
        if a[1] == a[-1]:
            a = "".join([X[i] for i in a])
            print(a)
            exit()
    if a[0] == 1 and s[0] == "x":
        if a[1] == a[-1]:
            a = "".join([X[i] for i in a])
            print(a)
            exit()
    if a[-0] == 1 and s[0] == "o":
        if a[1] != a[-1]:
            a = "".join([X[i] for i in a])
            print(a)
            exit()
print(-1)

Submission status: Wrong Answer

Solution code:
"""
sheep oXo xXx ⇨ True
wolf  oXx xXo ⇨ True 
２点決める

s[i] == "o" and a[i] == "W"  a[i+1] != a[i-1]
s[i] == "o" and a[i] == "S"  a[i+1] == a[i-1]
s[i] == "x" and a[i] == "W"  a[i+1] == a[i-1]
s[i] == "x" and a[i] == "S"  a[i+1] != a[i-1]
"""
n = int(input())
s = input()
# S -> 0, W -> 1
ds = [(0,0),(0,1),(1,0),(1,1)]

for d0,d1 in ds:
    a = [d0,d1]
    for i in range(1,n-1):
        if s[i] == "o" and a[i] == 0:
            a.append(a[i-1])
        elif s[i] == "x" and a[i] == 0:
            a.append(a[i-1]^1)
        elif s[i] == "o" and a[i] == 1:
            a.append(a[i-1]^1)
        else:
            a.append(a[i-1])
    # 帳尻があっているかどうか
    X = ["S","W"]
    # print(a)
    if a[n-1] == 0 and s[n-1] == "x":
        if a[0] != a[n-2]:
            a = "".join([X[i] for i in a])
            print(a)
            exit()
    if a[n-1] == 0 and s[n-1] == "o":
        if a[0] == a[n-2]:
            a = "".join([X[i] for i in a])
            print(a)
            exit()
    if a[n-1] == 1 and s[n-1] == "x":
        if a[0] == a[n-2]:
            a = "".join([X[i] for i in a])
            print(a)
            exit()
    if a[n-1] == 1 and s[n-1] == "o":
        if a[0] != a[n-2]:
            a = "".join([X[i] for i in a])
            print(a)
            exit()
print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
# S -> 0, W -> 1
ds = [(0,0),(0,1),(1,0),(1,1)]

for d0,d1 in ds:
    a = [d0,d1]
    for i in range(1,n-1):
        if s[i] == "o" and a[i] == 0:
            a.append(a[i-1])
        elif s[i] == "x" and a[i] == 0:
            a.append(a[i-1]^1)
        elif s[i] == "o" and a[i] == 1:
            a.append(a[i-1]^1)
        else:
            a.append(a[i-1])
    # 帳尻があっているかどうか
    X = ["S","W"]
    print(a)
    if a[n-1] == 0 and s[n-1] == "x":
        if a[0] != a[n-2]:
            a = "".join([X[i] for i in a])
            print(a)
            exit()
    if a[n-1] == 0 and s[n-1] == "o":
        if a[0] == a[n-2]:
            a = "".join([X[i] for i in a])
            print(a)
            exit()
    if a[n-1] == 1 and s[n-1] == "x":
        if a[0] == a[n-2]:
            a = "".join([X[i] for i in a])
            print(a)
            exit()
    if a[n-1] == 1 and s[n-1] == "o":
        if a[0] != a[n-2]:
            a = "".join([X[i] for i in a])
            print(a)
            exit()
print(-1)

Submission status: Wrong Answer

Solution code:
"""
sheep oXo xXx ⇨ True
wolf  oXx xXo ⇨ True 
２点決める

s[i] == "o" and a[i] == "W"  a[i+1] != a[i-1]
s[i] == "o" and a[i] == "S"  a[i+1] == a[i-1]
s[i] == "x" and a[i] == "W"  a[i+1] == a[i-1]
s[i] == "x" and a[i] == "S"  a[i+1] != a[i-1]
"""
n = int(input())
s = input()
# S -> 0, W -> 1
ds = [(0,0),(0,1),(1,0),(1,1)]

for d0,d1 in ds:
    a = [d0,d1]
    for i in range(1,n-1):
        if s[i] == "o" and a[i] == 0:
            a.append(a[i-1])
        elif s[i] == "x" and a[i] == 0:
            a.append(a[i-1]^1)
        elif s[i] == "o" and a[i] == 1:
            a.append(a[i-1]^1)
        else:
            a.append(a[i-1])
    # 帳尻があっているかどうか
    X = ["S","W"]
    if a[n-1] == 0 and s[n-1] == "x":
        if a[0] != a[-2]:
            a = "".join([X[i] for i in a])
            print(a)
            exit()
    if a[n-1] == 0 and s[n-1] == "o":
        if a[0] == a[-2]:
            a = "".join([X[i] for i in a])
            print(a)
            exit()
    if a[n-1] == 1 and s[n-1] == "x":
        if a[0] == a[-2]:
            a = "".join([X[i] for i in a])
            print(a)
            exit()
    if a[n-1] == 1 and s[n-1] == "o":
        if a[0] != a[-2]:
            a = "".join([X[i] for i in a])
            print(a)
            exit()
print(-1)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
s = input() #sys.stdin.readlineは最後が改行


def dfs(now,ans):

    if now == n-1:
        if s[now] == 'o' and ans[now] == 'S':
            if ans[now-1] == ans[0]:
                return ans
            else: return '-1'
        elif s[now] == 'o' and ans[now] == 'W':
            if ans[now-1] != ans[0]:
                return ans
            else: return '-1'
        elif s[now] == 'x' and ans[now] == 'S':
            if ans[now-1] != ans[0]:
                return ans
            else: return '-1'
        elif s[now] == 'x' and ans[now] == 'W':
            if ans[now-1] == ans[0]:
                return ans
            else: return '-1'
        else:
            return '-1'

    if s[now] == 'o' and ans[now] == 'S':
        if ans[now-1] == 'S':
            ans[now+1]= 'S'
            return dfs(now+1,ans)
        else:
            ans[now+1]= 'W'
            return dfs(now+1,ans)
    elif s[now] == 'o' and ans[now] == 'W':
        if ans[now-1] == 'S':
            ans[now+1]= 'W'
            return dfs(now+1,ans)
        else:
            ans[now+1]= 'S'
            return dfs(now+1,ans)
    elif s[now] == 'x' and ans[now] == 'S':
        if ans[now-1] == 'S':
            ans[now+1]= 'W'
            return dfs(now+1,ans)
        else:
            ans[now+1]= 'S'
            return dfs(now+1,ans)
    elif s[now] == 'x' and ans[now] == 'W':
        if ans[now-1] == 'S':
            ans[now+1]= 'S'
            return dfs(now+1,ans)
        else:
            ans[now+1]= 'W'
            return dfs(now+1,ans)

ans = ['A']*n
ANS= ['a']*4

if s[0]=='o':
    ans[:2]=['S','W']
    ans[-1]='W'
    ANS[0] = dfs(0,ans)[:]

    ans[:2]=['S','S']
    ans[-1]='S'
    ANS[1] = dfs(0,ans)[:]

    ans[:2]=['W','S']
    ans[-1]='W'
    ANS[2] = dfs(0,ans)[:]

    ans[:2]=['W','W']
    ans[-1]='S'
    ANS[3] = dfs(0,ans)[:]

else:
    ans[:2]=['S','S']
    ans[-1]='W'
    ANS[0] = dfs(0,ans)[:]

    ans[:2]=['S','W']
    ans[-1]='S'
    ANS[1] = dfs(0,ans)[:]

    ans[:2]=['W','S']
    ans[-1]='S'
    ANS[2] = dfs(0,ans)[:]

    ans[:2]=['W','W']
    ans[-1]='W'
    ANS[3] = dfs(0,ans)[:]

for i in range(4):
    if ANS[i] != '-1':
        print(*ANS[i],sep='')
        exit()

print(-1)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
s = input() #sys.stdin.readlineは最後が改行


def dfs(now,ans):

    if now == n-1:
        if s[now] == 'o' and ans[now] == 'S':
            if ans[now-1] == ans[0]:
                return ans
            else: return '-1'
        elif s[now] == 'o' and ans[now] == 'W':
            if ans[now-1] != ans[0]:
                return ans
            else: return '-1'
        elif s[now] == 'x' and ans[now] == 'S':
            if ans[now-1] != ans[0]:
                return ans
            else: return '-1'
        elif s[now] == 'x' and ans[now] == 'W':
            if ans[now-1] == ans[0]:
                return ans
            else: return '-1'
        else:
            return '-1'

    if s[now] == 'o' and ans[now] == 'S':
        if ans[now-1] == 'S':
            ans[now+1]= 'S'
            return dfs(now+1,ans)
        else:
            ans[now+1]= 'W'
            return dfs(now+1,ans)
    elif s[now] == 'o' and ans[now] == 'W':
        if ans[now-1] == 'S':
            ans[now+1]= 'W'
            return dfs(now+1,ans)
        else:
            ans[now+1]= 'S'
            return dfs(now+1,ans)
    elif s[now] == 'x' and ans[now] == 'S':
        if ans[now-1] == 'S':
            ans[now+1]= 'W'
            return dfs(now+1,ans)
        else:
            ans[now+1]= 'S'
            return dfs(now+1,ans)
    elif s[now] == 'x' and ans[now] == 'W':
        if ans[now-1] == 'S':
            ans[now+1]= 'S'
            return dfs(now+1,ans)
        else:
            ans[now+1]= 'W'
            return dfs(now+1,ans)

ans = ['A']*n
ANS= ['a']*4

if s[0]=='o':
    ans[:2]=['S','W']
    ans[-1]='W'
    ANS[0] = dfs(0,ans)[:]

    ans[:2]=['S','S']
    ans[-1]='S'
    ANS[1] = dfs(0,ans)[:]

    ans[:2]=['W','S']
    ans[-1]='W'
    ANS[2] = dfs(0,ans)[:]

    ans[:2]=['W','W']
    ans[-1]='S'
    ANS[3] = dfs(0,ans)[:]

else:
    ans[:2]=['S','S']
    ans[-1]='W'
    ANS[0] = dfs(0,ans)

    ans[:2]=['S','W']
    ans[-1]='S'
    ANS[1] = dfs(0,ans)

    ans[:2]=['W','S']
    ans[-1]='S'
    ANS[2] = dfs(0,ans)

    ans[:2]=['W','W']
    ans[-1]='W'
    ANS[3] = dfs(0,ans)

for i in range(4):
    if ANS[i] != '-1':
        print(*ANS[i],sep='')
        exit()

print(-1)

Submission status: Wrong Answer

Solution code:
# AtCoder Regular Contest 069
# D - Menagerie
# https://atcoder.jp/contests/arc069/tasks/arc069_b
import sys
N = int(input())
S = [1 if s == 'o' else 0 for s in input()]

tostr = ('W', 'S')


def f(a, b):
    prev = a
    first = current = b
    ans = []
    for s in S:
        ans.append(tostr[current])
        prev, current = current, prev ^ current ^ s
    if current == first:
        print(''.join(ans))
        sys.exit()

f(1, 1)
f(1, 0)
f(0, 1)
f(0, 0)

print('-1')

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
s = ns()
a = [['S','S'],['S','W'],['W','S'],['W','W']]

for b in a:
    for i in range(1,n):
        c = 0 if b[i] == 'S' else 1
        d = 0 if s[i] == 'o' else 1
        e = b[i-1] if not c^d else 'W' if b[i-1] == 'S' else 'S'
        b.append(e)
    c = 0 if b[-1] == 'S' else 1
    d = 0 if s[-1] == 'o' else 1
    e = 0 if b[-2] == b[1] else 1
    if b[0] == b[-1] and c^d == e:
        print(''.join(b[:-1]))
        exit()

print(-1)

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
s = ns()
a = [['S','S'],['S','W'],['W','S'],['W','W']]

for b in a:
    for i in range(1,n):
        c = 0 if b[i] == 'S' else 1
        d = 0 if s[i] == 'o' else 1
        e = b[i-1] if not c^d else 'W' if b[i-1] == 'S' else 'S'
        b.append(e)
    c = 0 if b[-1] == 'S' else 1
    d = 0 if s[-1] == 'o' else 1
    e = 0 if b[-2] == b[1] else 1
    if b[0] == b[-1] and c&d == e:
        print(''.join(b[:-1]))
        exit()

print(-1)

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
s = ns()
a = [['S','S'],['S','W'],['W','S'],['W','W']]

for b in a:
    for i in range(1,n):
        c = 0 if b[i] == 'S' else 1
        d = 0 if s[i] == 'o' else 1
        e = b[i-1] if not c^d else 'W' if b[i-1] == 'S' else 'S'
        b.append(e)
    if b[0] == b[-1]:
        print(''.join(b[:-1]))
        exit()

print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
flag = False
for i in range(4):
    if i == 0:
        ans = 'SS'
        past = 'S'
        cur = 'S'
        for j in range(1,n-1):
            if cur == 'S':
                if s[j] == 'o':
                    if past == 'S':
                        ans += 'S'
                    else:
                        ans += 'W'
                        past = 'S'
                        cur = 'W'
                else:
                    if past == 'S':
                        ans += 'W'
                        cur = 'W'
                    else:
                        ans += 'S'
                        past = 'S'
            else:
                if cur == 'W':
                    if s[j] == 'o':
                        if past == 'S':
                            ans += 'W'
                            past = 'W'
                        else:
                            ans += 'S'
                            cur = 'S'
                    else:
                        if past == 'S':
                            ans += 'S'
                            past = 'W'
                            cur = 'S'
                        else:
                            ans += 'W'
        if ans[len(ans)-1] == 'S':
            if s[n-1] == 'o':
                if ans[0] == ans[len(ans)-2]:
                    if s[0] == 'o':
                        if ans[1] == ans[len(ans)-1]:
                            flag = True
                            break
                    else:
                        if ans[1] != ans[len(ans)-1]:
                            flag = True
                            break
            else:
                if ans[0] != ans[len(ans)-2]:
                    if s[0] == 'o':
                        if ans[1] == ans[len(ans)-1]:
                            flag = True
                            break
                    else:
                        if ans[1] != ans[len(ans)-1]:
                            flag = True
                            break
        else:
            if s[n-1] == 'o':
                if ans[0] != ans[len(ans)-2]:
                    if s[0] == 'o':
                        if ans[1] == ans[len(ans)-1]:
                            flag = True
                            break
                    else:
                        if ans[1] != ans[len(ans)-1]:
                            flag = True
                            break
            else:
                if ans[0] == ans[len(ans)-2]:
                    if s[0] == 'o':
                        if ans[1] == ans[len(ans)-1]:
                            flag = True
                            break
                    else:
                        if ans[1] != ans[len(ans)-1]:
                            flag = True
                            break
    elif i == 1:
        ans = 'SW'
        past = 'S'
        cur = 'W'
        for j in range(1,n-1):
            if cur == 'S':
                if s[j] == 'o':
                    if past == 'S':
                        ans += 'S'
                    else:
                        ans += 'W'
                        past = 'S'
                        cur = 'W'
                else:
                    if past == 'S':
                        ans += 'W'
                        cur = 'W'
                    else:
                        ans += 'S'
                        past = 'S'
            else:
                if cur == 'W':
                    if s[j] == 'o':
                        if past == 'S':
                            ans += 'W'
                            past = 'W'
                        else:
                            ans += 'S'
                            cur = 'S'
                    else:
                        if past == 'S':
                            ans += 'S'
                            past = 'W'
                            cur = 'S'
                        else:
                            ans += 'W'
        if ans[len(ans)-1] == 'S':
            if s[n-1] == 'o':
                if ans[0] == ans[len(ans)-2]:
                    if s[0] == 'o':
                        if ans[1] == ans[len(ans)-1]:
                            flag = True
                            break
                    else:
                        if ans[1] != ans[len(ans)-1]:
                            flag = True
                            break
            else:
                if ans[0] != ans[len(ans)-2]:
                    if s[0] == 'o':
                        if ans[1] == ans[len(ans)-1]:
                            flag = True
                            break
                    else:
                        if ans[1] != ans[len(ans)-1]:
                            flag = True
                            break
        else:
            if s[n-1] == 'o':
                if ans[0] != ans[len(ans)-2]:
                    if s[0] == 'o':
                        if ans[1] == ans[len(ans)-1]:
                            flag = True
                            break
                    else:
                        if ans[1] != ans[len(ans)-1]:
                            flag = True
                            break
            else:
                if ans[0] == ans[len(ans)-2]:
                    if s[0] == 'o':
                        if ans[1] == ans[len(ans)-1]:
                            flag = True
                            break
                    else:
                        if ans[1] != ans[len(ans)-1]:
                            flag = True
                            break
    elif i == 2:
        ans = 'WS'
        past = 'W'
        cur = 'S'
        for j in range(1,n-1):
            if cur == 'S':
                if s[j] == 'o':
                    if past == 'S':
                        ans += 'S'
                    else:
                        ans += 'W'
                        past = 'S'
                        cur = 'W'
                else:
                    if past == 'S':
                        ans += 'W'
                        cur = 'W'
                    else:
                        ans += 'S'
                        past = 'S'
            else:
                if cur == 'W':
                    if s[j] == 'o':
                        if past == 'S':
                            ans += 'W'
                            past = 'W'
                        else:
                            ans += 'S'
                            cur = 'S'
                    else:
                        if past == 'S':
                            ans += 'S'
                            past = 'W'
                            cur = 'S'
                        else:
                            ans += 'W'
        if ans[len(ans)-1] == 'S':
            if s[n-1] == 'o':
                if ans[0] == ans[len(ans)-2]:
                    if s[0] == 'o':
                        if ans[1] == ans[len(ans)-1]:
                            flag = True
                            break
                    else:
                        if ans[1] != ans[len(ans)-1]:
                            flag = True
                            break
            else:
                if ans[0] != ans[len(ans)-2]:
                    if s[0] == 'o':
                        if ans[1] != ans[len(ans)-1]:
                            flag = True
                            break
                    else:
                        if ans[1] == ans[len(ans)-1]:
                            flag = True
                            break
        else:
            if s[n-1] == 'o':
                if ans[0] != ans[len(ans)-2]:
                    if s[0] == 'o':
                        if ans[1] != ans[len(ans)-1]:
                            flag = True
                            break
                    else:
                        if ans[1] == ans[len(ans)-1]:
                            flag = True
                            break
            else:
                if ans[0] == ans[len(ans)-2]:
                    if s[0] == 'o':
                        if ans[1] != ans[len(ans)-1]:
                            flag = True
                            break
                    else:
                        if ans[1] == ans[len(ans)-1]:
                            flag = True
                            break
    else:
        ans = 'WW'
        past = 'W'
        cur = 'W'
        for j in range(1,n-1):
            if cur == 'S':
                if s[j] == 'o':
                    if past == 'S':
                        ans += 'S'
                    else:
                        ans += 'W'
                        past = 'S'
                        cur = 'W'
                else:
                    if past == 'S':
                        ans += 'W'
                        cur = 'W'
                    else:
                        ans += 'S'
                        past = 'S'
            else:
                if cur == 'W':
                    if s[j] == 'o':
                        if past == 'S':
                            ans += 'W'
                            past = 'W'
                        else:
                            ans += 'S'
                            cur = 'S'
                    else:
                        if past == 'S':
                            ans += 'S'
                            past = 'W'
                            cur = 'S'
                        else:
                            ans += 'W'
        if ans[len(ans)-1] == 'S':
            if s[n-1] == 'o':
                if ans[0] == ans[len(ans)-2]:
                    if s[0] == 'o':
                        if ans[1] == ans[len(ans)-1]:
                            flag = True
                            break
                    else:
                        if ans[1] != ans[len(ans)-1]:
                            flag = True
                            break
            else:
                if ans[0] != ans[len(ans)-2]:
                    if s[0] == 'o':
                        if ans[1] == ans[len(ans)-1]:
                            flag = True
                            break
                    else:
                        if ans[1] != ans[len(ans)-1]:
                            flag = True
                            break
        else:
            if s[n-1] == 'o':
                if ans[0] != ans[len(ans)-2]:
                    if s[0] == 'o':
                        if ans[1] == ans[len(ans)-1]:
                            flag = True
                            break
                    else:
                        if ans[1] != ans[len(ans)-1]:
                            flag = True
                            break
            else:
                if ans[0] == ans[len(ans)-2]:
                    if s[0] == 'o':
                        if ans[1] == ans[len(ans)-1]:
                            flag = True
                            break
                    else:
                        if ans[1] != ans[len(ans)-1]:
                            flag = True
                            break
if flag:
    print(ans)
else:
    print(-1)