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 TBD = ' ';
        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)
        {
            //1番目をS固定
            bool[] ling = new bool[N];
            for(int i = 0; i < N; ++i)
            {
                ling[i] = true;//全部羊にする
            }
            int loopIdx = 0;
            for (loopIdx = 0; loopIdx < N; ++loopIdx)
            {
                bool checkCnt = false;
                for (int i = 0; i < N; ++i)
                {
                    //i番目の発言
                    bool call = inputString[i] == CORRECT ? true : false;

                    //発言者がSHEEPなら
                    int preIdx = (i != 0) ? i - 1 : (int)N - 1;
                    int nextIdx = (i != N - 1) ? i + 1 : 0;
                    bool nextAnimal = decideAnimal(ling[i], ling[preIdx], call);
                    if (nextAnimal != ling[nextIdx])
                    {
                        //矛盾発生
                        checkCnt = true;
                    }
                    ling[nextIdx] = nextAnimal;
                }
                //全動物をチェックした
                if (checkCnt == false)
                {
                    //矛盾なくいけたので、これが回答
                    break;
                }
                else
                {
                    //矛盾があったのでもう一回
                }
            }



            string ans = "";
            if (loopIdx < N)
            {
                foreach (var b in ling)
                {
                    ans += b ? SHEEP : WOLF;
                }
            }
            else
            {
                ans = NOT_FOUND;
            }
            return ans;
        }
        /// <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 bool decideAnimal(bool Animal, bool PreAnimal, bool call)
        {

            if (Animal == true)
            {
                if (call == true)
                {
                    return PreAnimal;
                }
                else
                {//call == false
                    return !PreAnimal;
                }
            }
            else
            { //Anima == false => Wolf
                if (call == true)
                {
                    return !PreAnimal;
                }
                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;//桁あふれ対策
        }
    }
}