Problem:
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

Dice I

Write a program to simulate rolling a dice, which can be constructed by the following net.

As shown in the figures, each face is identified by a different label from 1 to 6.

Write a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures.

Input

In the first line, six integers assigned to faces are given in ascending order of their corresponding labels.

In the second line, a string which represents a sequence of commands, is given. The command is one of 'E', 'N', 'S' and 'W' representing four directions shown in the above figures.

Output

Print the integer which appears on the top face after the simulation.

Constraints

$0 \leq $ the integer assigned to a face $ \leq 100$

$0 \leq $ the length of the command $\leq 100$

Sample Input 1

1 2 4 8 16 32
SE

Sample Output 1

8

You are given a dice where 1, 2, 4, 8, 16 are 32 are assigned to a face labeled by 1, 2, ..., 6 respectively. After you roll the dice to the direction S and then to the direction E, you can see 8 on the top face.

Sample Input 2

1 2 4 8 16 32
EESWN

Sample Output 2

32

Solution in C# (judge verdict: Accepted)

using System;

namespace AOJ
{
    class Program
    {
        
        static void Main(string[] args)
        {
            var read = Console.ReadLine();
            var dice_surface_arry = read.Split();
            var dice_obj1 = new dice(dice_surface_arry);

            read = Console.ReadLine();
            Console.WriteLine(dice_obj1.dice_emulate(read));
            

            //read = Console.ReadLine();
            //dice_surface_arry = read.Split();
            //var dice_ob2 = new dice(dice_surface_arry);

            //if(dice_obj1.dice_Comparison(dice_ob2.get_sueface()))
           // {
           //     Console.WriteLine("Yes");
           // }
            //else
            //{
                //Console.WriteLine("No");
           // }

        }

    }

    //?????????????????????
    class dice
    {
        //?????????????????¨??¢
        int[] dice_surface = new int [6];
        
        //??????????????????????????¨??¢??????????????£?????????
        public dice(string[] sueface_temp)
        {
            for(var i=0;i<dice_surface.Length;i++)
            {
                dice_surface[i] = int.Parse(sueface_temp[i]);
            }
        }

        public int[] get_sueface()
        {
            return dice_surface;
        }

        //?????????????????¨?????\??¬????????????????????????
        public int dice_emulate(string order)
        {
            int[] dice_temp = new int[6];

            for (var i = 0; i < order.Length;i++ )
            {
                switch(order.Substring(i,1))
                {
                    case"N":
                        {

                            dice_vertical_rotation("up");
                            break;
                        }
                    case "S":
                        {
                            dice_vertical_rotation("down");
                            break;
                        }
                    case"E":
                        {
                            dice_temp[0] = dice_surface[0];
                            dice_temp[2] = dice_surface[2];
                            dice_temp[3] = dice_surface[3];
                            dice_temp[5] = dice_surface[5];

                            dice_surface[0] = dice_temp[3];
                            dice_surface[2] = dice_temp[0];
                            dice_surface[3] = dice_temp[5];
                            dice_surface[5] = dice_temp[2];

                            break;
                        }

                    case"W":
                        {
                            dice_temp[0] = dice_surface[0];
                            dice_temp[2] = dice_surface[2];
                            dice_temp[3] = dice_surface[3];
                            dice_temp[5] = dice_surface[5];

                            dice_surface[3] = dice_temp[0];
                            dice_surface[0] = dice_temp[2];
                            dice_surface[5] = dice_temp[3];
                            dice_surface[2] = dice_temp[5];
                            break;
                        }
                }

            }

                return dice_surface[0];
        }

        //???????????????2??¢?????????????????¨???????????¢???????????????????????????
        public int dice_direction(int up,int front)
        {
            int directio_up=0,direction_front=0;

            //???????????£?????????????????¢????????????
            for (var i = 0; i < dice_surface.Length;i++ )
            {
                if(dice_surface[i]==up)
                {
                    directio_up = i+1;
                }
            }

            for (var i = 0; i < dice_surface.Length; i++)
            {
                if (dice_surface[i] == front)
                {
                    direction_front = i+1;
                }
            }

            //???????????¢??????????????????????????????????????????
            switch (directio_up)
            {
                case 1:
                    {
                        switch(direction_front)
                        {
                            case 2:
                                return dice_surface[2];

                            case 3:
                                return dice_surface[4];

                            case 4:
                                return dice_surface[1];

                            case 5:
                                return dice_surface[3];
                        }

                        break;
                    }
                case 2:
                    {
                        switch (direction_front)
                        {
                            case 1:
                                return dice_surface[3];

                            case 3:
                                return dice_surface[0];

                            case 4:
                                return dice_surface[5];

                            case 6:
                                return dice_surface[2];
                        }
                        break;
                    }
                case 3:
                    {
                        switch (direction_front)
                        {
                            case 1:
                                return dice_surface[1];

                            case 2:
                                return dice_surface[5];

                            case 5:
                                return dice_surface[0];

                            case 6:
                                return dice_surface[4];
                        }
                        break;
                    }

                case 4:
                    {
                        switch (direction_front)
                        {
                            case 1:
                                return dice_surface[4];

                            case 2:
                                return dice_surface[0];

                            case 5:
                                return dice_surface[5];

                            case 6:
                                return dice_surface[1];
                        }
                        break;
                    }
                case 5:
                    {
                        switch (direction_front)
                        {
                            case 1:
                                return dice_surface[2];

                            case 3:
                                return dice_surface[5];

                            case 4:
                                return dice_surface[0];

                            case 6:
                                return dice_surface[3];
                        }
                        break;
                    }
                case 6:
                    {
                        switch (direction_front)
                        {
                            case 2:
                                return dice_surface[3];

                            case 3:
                                return dice_surface[1];

                            case 4:
                                return dice_surface[4];

                            case 5:
                                return dice_surface[2];
                        }
                        break;
                    }
            }

            return 0;

        }

        void dice_horizone_rotation(string course)
        {
            switch(course)
            {
                case"right":
                    {

                        break;
                    }
                case"left":
                    {

                        break;
                    }
            }
        }
        void dice_vertical_rotation(string course)
        {
            int[] dice_temp = new int[6];

            switch(course)
            {
                case"up":
                    {
                        dice_temp[0] = dice_surface[0];
                        dice_temp[1] = dice_surface[1];
                        dice_temp[4] = dice_surface[4];
                        dice_temp[5] = dice_surface[5];

                        dice_surface[4] = dice_temp[0];
                        dice_surface[0] = dice_temp[1];
                        dice_surface[1] = dice_temp[5];
                        dice_surface[5] = dice_temp[4];
                        break;
                    }
                case"down":
                    {
                        dice_temp[0] = dice_surface[0];
                        dice_temp[1] = dice_surface[1];
                        dice_temp[4] = dice_surface[4];
                        dice_temp[5] = dice_surface[5];

                        dice_surface[0] = dice_temp[4];
                        dice_surface[1] = dice_temp[0];
                        dice_surface[5] = dice_temp[1];
                        dice_surface[4] = dice_temp[5];
                        break;
                    }
            }
        }
        void dice_z_axis_rotation(string coures)
        {
            switch(coures)
            {
                case"right":
                    {

                        break;
                    }
                case"left":
                    {

                        break;
                    }
            }
        }

       // public bool dice_Comparison(int[] Specimen)
       // {

            
       // }

    }
}