Time limit
2s
Memory limit
128 MB
Sejun lives in a palace whose floor has N columns and M rows. He wants visitors to walk as much as possible before reaching him, so a spiral path is installed.
Visitors enter at the southwestern corner. They first keep moving east. Whenever the cell in front of them is outside the palace or has already been visited, they turn left and continue moving forward. The diagram below shows the visiting order for a palace with N = 6 and M = 4; letters are visited in alphabetical order.
nmlkjioxwvuhpqrstgabcdefSejun wants to stay at the cell where this spiral walk ends. Write a program that prints the coordinate of that cell.
The southwestern corner is (0, 0), the southeastern corner is (N-1, 0), and the northeastern corner is (N-1, M-1).
The first line contains two natural numbers N and M. Each is at most 5000.
Print the coordinate x y of the cell where the spiral walk ends.
nmlkjioxwvuhpqrstgabcdef