{"trustable":false,"sections":[{"title":"","value":{"format":"MD","content":"The **N** students of the Institute of Urban Transport (IUT) are going to sit for their Semester Final Exam. You have been assigned to make their seat plan. You have **N** seats in a horizontal line numbered from **1** to **N** corresponding to the student IDs of each student. You want to arrange the seats in a specific order. So you give the following commands:\n- **1 X Y**: move seat **X** to the left of **Y** (ignore this if **X** is already on the left of **Y**)\n- **2 X Y**: move seat **X** to the right of **Y** (ignore this if **X** is already on the right of **Y**)\n- **3 X Y**: Swap seat **X** and **Y**\n- **4**: Reverse the whole line\nwhere **X ≠ Y**.\n\nTo check whether the final configuration is OK, you will take the seats in the odd-indexed positions, and sum their corresponding IDs (Remember, the positions are numbered from 1 to N). Design an automated system to find out the result."}},{"title":"Input","value":{"format":"MD","content":"There will be at most **10** test cases.\nEach case begins with two space-separated integers **N** and **M (1 ≤ N, M ≤ 10\u003csup\u003e5\u003c/sup\u003e)**.\nEach of the following **M** lines contains a command."}},{"title":"Output","value":{"format":"MD","content":"For each test case, print the case number and the required sum."}},{"title":"Sample Input","value":{"format":"MD","content":"`6 4`\n`1 1 4`\n`2 3 5`\n`3 1 6`\n`4`\n`6 3`\n`1 1 4`\n`2 3 5`\n`3 1 6`"}},{"title":"Sample Output","value":{"format":"MD","content":"`Case 1: 12`\n`Case 2: 9`"}},{"title":"Explanation","value":{"format":"MD","content":"For the first test case,\nn \u003d 6, so there are 6 seats: 1 2 3 4 5 6\nAfter executing 1 1 4 ➡ 2 3 1 4 5 6\nAfter executing 2 3 5 ➡ 2 1 4 5 3 6\nAfter executing 3 1 6 ➡ 2 6 4 5 3 1\nAfter executing 4 ➡ 1 3 5 4 6 2\nSum of odd-indexed IDs: (1 + 5 + 6) \u003d 12"}}]}