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 in C# (Mono 4.6.2.0) (judge verdict: Wrong Answer)

//
// ABC055D
// URL : https://atcoder.jp/contests/abc055/tasks/abc055_d
// 
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

namespace AtCoder
{
    class ABC055D
    {
        static readonly string NOT_FOUND = "-1";
        static readonly char SHEEP = 'S';
        static readonly char WOLF = 'W';
        static readonly char CORRECT = 'o';
        static readonly char WRONG = 'x';
        static void Main(string[] args)
        {
            preprocess();
            long N = long.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            var ans = check(N,s);

            Console.WriteLine(ans);
            Console.Out.Flush();
        }

        static string check(long N, string inputString)
        {
            bool found = false;
            var firstAnimals =  new char[] { SHEEP, SHEEP,  WOLF, WOLF };
            var secondAnimals = new char[] { SHEEP, WOLF, SHEEP, WOLF };
            char[] ring = new char[N];
            for (int i = 0; i < 4; ++i)
            {
                createRing(N, inputString, firstAnimals[i], secondAnimals[i], out ring);
                if(judgeRing(ring, inputString) == true)
                {
                    found = true;
                    break;
                }
            }
            return (found) ? new string(ring) : NOT_FOUND;
        }

        public static void createRing(long N, string inputString, char firstAnimal, char SecondAnimal, out char[] ring)
        {
            ring = new char[(int)N];
            ring[0] = firstAnimal;
            ring[1] = SecondAnimal;
            //動物列を生成
            for (int i = 1; i < N; ++i)
            {
                //index計算
                int preIdx = (i != 0) ? i - 1 : (int)N - 1;
                int nextIdx = (i != N - 1) ? i + 1 : 0;

                //次の動物を決定
                var nextAnimal = decideAnimal(ring[i], ring[preIdx], inputString[i]);
                ring[nextIdx] = nextAnimal;
            }
        }
        /// <summary>
        /// 動物列が仮定に沿っているか判定する
        /// </summary>
        /// <param name="ring">検査動物列</param>
        /// <param name="inputString">入力文字列</param>
        /// <returns></returns>
        public static bool judgeRing(char[] ring, string inputString)
        {
            var finalIdx = ring.Length - 1;
            //作られた動物列から、仮定として与えた部分を推測し、それが動物列作成時に与えた仮定と一致しているか見る
            //動物列途中(1,2番目以外)の状況は仮定と一致するように作成しているため、問題ない
            var Animal1st = decideAnimal(ring[finalIdx], ring[finalIdx-1], inputString[finalIdx]);
            var Animal2nd = decideAnimal(ring[0], ring[finalIdx], inputString[0]);
            return Animal1st == ring[0] && Animal2nd == ring[1];
        }
        /// <summary>
        /// 動物を決定する
        /// </summary>
        /// <param name="Animal">対象となる動物。trueならSHEEP, falseならWOLF</param>
        /// <param name="PreAnimal">対象の前に並んでいる動物。trueならSHEEP, falseならWOLF</param>
        /// <param name="call">trueなら'o', falseなら'x'</param>
        /// <returns></returns>
        public static char decideAnimal(char Animal, char PreAnimal, char call)
        {
            //対象となる動物が
            if (Animal == SHEEP)//羊の場合
            {
                if (call == CORRECT)
                {
                    return PreAnimal;
                }
                else
                {//call == false
                    return (PreAnimal == SHEEP) ? WOLF : SHEEP;
                }
            }
            else
            { //Animal == false => Wolf. 狼の場合
                if (call == CORRECT)
                {
                    return (PreAnimal == SHEEP) ? WOLF : SHEEP;
                }
                else
                {
                    return PreAnimal;
                }
            }
        }

        //---------------------------------------------------------------------------------
        /// <summary>
        /// 
        /// </summary>
        public static void preprocess()
        {
            //出力高速化
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
        }


        /// <summary>
        /// 与えられた数が素数かどうかを計算する
        /// </summary>
        /// <param name="num">対象数</param>
        /// <returns>true:素数, false:素数ではない(合成数)</returns>
        public static bool isPrime(int num)
        {
            if (num < 2) return false;
            else if (num == 2) return true;
            else if (num % 2 == 0) return false;

            double sqrtNum = Math.Sqrt(num);
            for (int i = 3; i <= sqrtNum; i += 2)
            {
                if (num % i == 0)
                {
                    return false;
                }
            }
            return true;
        }

        /// <summary>
        /// 順列mPnを計算する
        /// </summary>
        /// <param name="m"></param>
        /// <param name="n"></param>
        /// <returns></returns>
        public static long Permutation(long m, long n)
        {
            long ret = 1;
            for(var i = 0; i < n; ++i)
            {
                ret *= m - i;
            }
            return ret;
        }
        /// <summary>
        /// 組み合わせmCnを計算する
        /// </summary>
        /// <param name="m"></param>
        /// <param name="n"></param>
        /// <returns></returns>
        public static long Combination(long m, long n)
        {
            if(m == n || n == 0)
            {
                return 1;
            }
            long ans = 1;
            for(var i = 0; i <= n; ++i)
            {
                ans *= (m - i + 1) / i;
            }
            return ans;
        }

        static long Gcd(long m, long n)
        {
            if (n == 0) return m;
            return Gcd(n, m % n);
        }

        static long Lcm(long m, long n)
        {
            var gcd = Gcd(m, n);
            //return (m * n) / gcd;
            return m / gcd * n;//桁あふれ対策
        }
    }
}