{"raw_statement":[{"iden":"statement","content":"The Berland State Building is the highest building in the capital of Berland. Curious Polikarp was studying the principle of operation of an elevator in the Berland State Building for a quite a while. Recently he has finally understood the algorithm behind its operation, in case a person enters the elevator on the floor f and presses the floor buttons e1, e2, ..., en one by one. The buttons are pressed sequentially but very quickly while the elevator is still located on the floor f. All the pressed buttons are distinct and differ from the floor f. No other button pressings are considered in this problem.\n\nAfter the buttons e1, e2, ..., en have been pressed, all of them become highlighted and the elevator starts moving according the following rules: \n\nNow, when the principle of the elevator's operation is clear, Polikarp wants to experiment with the elevator's movements without the elevator itself. He wants to write a program that simulates elevator's operation. Unfortunately, he didn't attend any programming lessons and it's a challenge for him. Can you please help Polikarp and write a program which will simulate movements of the elevator?\n\nThe first line of input contains a pair of integers n, f (1 ≤ n, f ≤ 100), where n — amount of pressings made, f — index of the current floor where all these pressings were made. The second line contains distinct integers e1, e2, ..., en (1 ≤ ei ≤ 100, ei ≠ f) — buttons indices in the order they were pressed.\n\nOutput all the floors where the elevator stops, in a chronological order of the stops.\n\n"},{"iden":"input","content":"The first line of input contains a pair of integers n, f (1 ≤ n, f ≤ 100), where n — amount of pressings made, f — index of the current floor where all these pressings were made. The second line contains distinct integers e1, e2, ..., en (1 ≤ ei ≤ 100, ei ≠ f) — buttons indices in the order they were pressed."},{"iden":"output","content":"Output all the floors where the elevator stops, in a chronological order of the stops."},{"iden":"examples","content":"Input4 510 9 2 1Output9 10 2 1 Input4 32 4 1 5Output2 4 1 5 "}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ n, f \\in \\mathbb{Z} $ with $ 1 \\leq n, f \\leq 100 $.  \nLet $ E = (e_1, e_2, \\dots, e_n) $ be a sequence of distinct integers such that $ 1 \\leq e_i \\leq 100 $ and $ e_i \\neq f $ for all $ i \\in \\{1, \\dots, n\\} $.\n\n**Constraints**  \n1. $ 1 \\leq n \\leq 100 $  \n2. $ 1 \\leq f \\leq 100 $  \n3. $ e_i \\neq f $ for all $ i \\in \\{1, \\dots, n\\} $  \n4. $ e_i \\neq e_j $ for all $ i \\neq j $\n\n**Objective**  \nSimulate the elevator movement starting at floor $ f $, processing button presses in order $ e_1, e_2, \\dots, e_n $, and output the sequence of floors where the elevator stops, following these rules:  \n- The elevator moves in the direction of the first pressed button.  \n- It continues in that direction, stopping at every pressed button in that direction (in order of increasing/decreasing floor number).  \n- Once no more buttons remain in the current direction, it reverses direction and continues to the next closest button in the new direction.  \n- The process repeats until all buttons are visited.  \n\nLet $ S = (s_1, s_2, \\dots, s_m) $ be the sequence of stop floors in chronological order, where $ s_1 = f $ is not output (initial position), and each subsequent $ s_j $ is a floor where the elevator halts after moving.  \nOutput $ S $, excluding the initial floor $ f $.","simple_statement":"You are given a starting floor f and a sequence of n button presses. The elevator starts at floor f and moves to each pressed button in the exact order they were pressed, stopping at each one. Print all floors where the elevator stops, in order.","has_page_source":false}