Min and Max
Two kittens, Min and Max, have written a sequence of integers on a sheet of paper and are playing a game with the following rules: On each turn, a kitten can choose two adjacent numbers and replace them with either their minimum or maximum. The kittens take turns, and the game continues until only one number remains. Kitten Min aims to make the final number as small as possible, while kitten Max wants it to be as large as possible.
Given that both kittens are infinitely intelligent and play optimally, determine the number that will remain on the paper at the end of the game.
Input
The input begins with a single integer n, representing the number of integers written by the kittens (1 ≤ n ≤ 5·10^7). The second line contains the name of the kitten who takes the first turn: "Min" if kitten Min starts, or "Max" if kitten Max starts. Due to the potential length of the sequence, you are provided with numbers 0 ≤ c_1, a, b < 2^32, and each element of the sequence is generated from the previous one using the formula:
c_i = (c_{i-1}·a + b) mod 2^32.
Output
Output the single number that will remain on the sheet of paper at the conclusion of the game.