using System; using System.Linq; using System.Collections.Generic; namespace yukicoder { class pg { static void Main(string[] args) { var line = Console.ReadLine().Split(' ').Select(c => int.Parse(c)).ToList(); int N = line[0]; int M = line[1]; var nums = Console.ReadLine().Split(' ').Select(c => int.Parse(c)).ToList(); string S = Console.ReadLine(); var linkedList = new LinkedList(nums); for(int i = 0;i < M;i++) { if(S[i] == 'R') { linkedList.AddFirst(0); linkedList.Last.Previous.Value += linkedList.Last.Value; linkedList.RemoveLast(); }else { linkedList.AddLast(0); linkedList.First.Next.Value += linkedList.First.Value; linkedList.RemoveFirst(); } } var ans = linkedList.ToArray(); foreach(int i in ans) { Console.Write(i); } } } }