{"problem":{"name":"4. North East South West","description":{"content":"Ahmad is playing a game with his friend. The game works like this. Ahmad will start by facing north, then he close his eye. When his friend say \"right\" he will rotate clockwise by 90 degree. So if he ","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF102154"},"statements":[{"statement_type":"Markdown","content":"Ahmad is playing a game with his friend. The game works like this. Ahmad will start by facing north, then he close his eye. When his friend say \"right\" he will rotate clockwise by 90 degree. So if he was facing north, he will now face east. If he was facing east, he will now face south. If his friend says \"left\", he will rotate counter-clockwise by 90 degree. So if he is facing north, he will now face west. If he was facing west, he will now face south. When his friend say \"back\" he can either rotate clockwise or counter-clockwise by 180 degree. So if he was facing north, he will now face south. If he was facing west, he will now face east.\n\nAfter several command, Ahmad will now guess which direction he is facing. Help Ahmad figure-out which direction he is facing now.\n\nInput starts with a number $n, (1 <= n <= 10^5)$. The next $n$ lines each consist of a single word which is either, \"left\", \"right\" or \"back\".\n\nOutput a single word, which can be either \"north\", \"east\", \"south\", \"west\". \n\n## Input\n\nInput starts with a number $n, (1 <= n <= 10^5)$. The next $n$ lines each consist of a single word which is either, \"left\", \"right\" or \"back\".\n\n## Output\n\nOutput a single word, which can be either \"north\", \"east\", \"south\", \"west\". \n\n[samples]","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ n \\in \\mathbb{Z} $ be the number of commands, with $ 1 \\leq n \\leq 10^5 $.  \nLet $ C = (c_1, c_2, \\dots, c_n) $ be a sequence of commands, where each $ c_i \\in \\{\\text{left}, \\text{right}, \\text{back}\\} $.  \nLet the initial direction be $ d_0 = \\text{north} $.  \nMap directions to integers modulo 4:  \n- $ \\text{north} \\mapsto 0 $  \n- $ \\text{east} \\mapsto 1 $  \n- $ \\text{south} \\mapsto 2 $  \n- $ \\text{west} \\mapsto 3 $  \n\n**Constraints**  \nEach command $ c_i $ transforms the current direction $ d \\in \\{0,1,2,3\\} $ as follows:  \n- If $ c_i = \\text{right} $, then $ d \\leftarrow (d + 1) \\mod 4 $  \n- If $ c_i = \\text{left} $, then $ d \\leftarrow (d - 1) \\mod 4 $  \n- If $ c_i = \\text{back} $, then $ d \\leftarrow (d + 2) \\mod 4 $  \n\n**Objective**  \nCompute the final direction $ d_n \\in \\{0,1,2,3\\} $ after applying all $ n $ commands sequentially, starting from $ d_0 = 0 $, and output the corresponding direction name.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF102154","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}