A text editor holds a string of N characters. Mirko performs M steps. In each step he picks two numbers A and B and reverses the substring made of all characters from position A to position B, inclusive. To reverse it, he swaps the first character of the substring with the last one, the second with the second to last, and so on. Positions in the string are numbered from 1 to N.
Write a program that finds the final state of the string after all reversals.