Train

题意翻译

偷渡者(Stowaway)和管理员(Controller)在火车上玩游戏.火车有编号$1\sim n$的$n$节车厢,其中$1$号车厢是头,$n$号车厢是尾.火车每分钟处于运行或停靠状态.每分钟两个玩家都会移动,且偷渡者先移动.任意时刻两玩家都知道对方的位置. 管理员有一个移动方向——朝着火车头或火车尾.每分钟他会移动到他的移动方向的下一节车厢,当他在$1$号或$n$号车厢时转向. 偷渡者的移动与火车的状态有关.若火车该分钟处于运行状态,则偷渡者可移动到相邻的一节车厢或留在所处车厢;若火车处于停靠状态且不是终点站,他会下车并从任一节车厢上车.若火车停靠若干分钟,则每分钟他都会下车再重新上车. 若某一分钟偷渡者和管理员处于同一节车厢,则管理员胜.若到终点站后偷渡者仍未负,则偷渡者胜.若偷渡者负,则希望他尽量晚负.两人都采取最优策略,问最后的胜者.若管理员胜,需他抓到偷渡者的分钟数(从$1$开始). 第一行输入三个整数$n,m,k\ \ (2\leq n\leq 50,1\leq m,k\leq n,m\neq k)$,分别表示火车的车厢数、偷渡者的初始位置、管理员的初始位置.第二行输入一个字符串表示管理员初始时的移动方向,其中"to head"表示他向火车头移动,"to tail"表示他向火车尾移动.数据保证他移动的方向至少还有一节车厢.第三行输入一个长度不超过$200$的$0-1$串表示每分钟火车的状态,其中$0$表示火车处于运行状态,$1$表示火车处于停靠状态. Translated By @Hytidel

题目描述

A stowaway and a controller play the following game. The train is represented by $ n $ wagons which are numbered with positive integers from $ 1 $ to $ n $ from the head to the tail. The stowaway and the controller are initially in some two different wagons. Every minute the train can be in one of two conditions — moving or idle. Every minute the players move. The controller's move is as follows. The controller has the movement direction — to the train's head or to its tail. During a move the controller moves to the neighbouring wagon correspondingly to its movement direction. If at the end of his move the controller enters the $ 1 $ -st or the $ n $ -th wagon, that he changes the direction of his movement into the other one. In other words, the controller cyclically goes from the train's head to its tail and back again during all the time of a game, shifting during each move by one wagon. Note, that the controller always have exactly one possible move. The stowaway's move depends from the state of the train. If the train is moving, then the stowaway can shift to one of neighbouring wagons or he can stay where he is without moving. If the train is at a station and is idle, then the stowaway leaves the train (i.e. he is now not present in any train wagon) and then, if it is not the terminal train station, he enters the train again into any of $ n $ wagons (not necessarily into the one he's just left and not necessarily into the neighbouring one). If the train is idle for several minutes then each such minute the stowaway leaves the train and enters it back. Let's determine the order of the players' moves. If at the given minute the train is moving, then first the stowaway moves and then the controller does. If at this minute the train is idle, then first the stowaway leaves the train, then the controller moves and then the stowaway enters the train. If at some point in time the stowaway and the controller happen to be in one wagon, then the controller wins: he makes the stowaway pay fine. If after a while the stowaway reaches the terminal train station, then the stowaway wins: he simply leaves the station during his move and never returns there again. At any moment of time the players know each other's positions. The players play in the optimal way. Specifically, if the controller wins, then the stowaway plays so as to lose as late as possible. As all the possible moves for the controller are determined uniquely, then he is considered to play optimally always. Determine the winner.

输入输出格式

输入格式


The first line contains three integers $ n $ , $ m $ and $ k $ . They represent the number of wagons in the train, the stowaway's and the controller's initial positions correspondingly ( $ 2<=n<=50 $ , $ 1<=m,k<=n $ , $ m≠k $ ). The second line contains the direction in which a controller moves. "to head" means that the controller moves to the train's head and "to tail" means that the controller moves to its tail. It is guaranteed that in the direction in which the controller is moving, there is at least one wagon. Wagon $ 1 $ is the head, and wagon $ n $ is the tail. The third line has the length from $ 1 $ to $ 200 $ and consists of symbols "0" and "1". The $ i $ -th symbol contains information about the train's state at the $ i $ -th minute of time. "0" means that in this very minute the train moves and "1" means that the train in this very minute stands idle. The last symbol of the third line is always "1" — that's the terminal train station.

输出格式


If the stowaway wins, print "Stowaway" without quotes. Otherwise, print "Controller" again without quotes, then, separated by a space, print the number of a minute, at which the stowaway will be caught.

输入输出样例

输入样例 #1

5 3 2
to head
0001001

输出样例 #1

Stowaway

输入样例 #2

3 2 1
to tail
0001

输出样例 #2

Controller 2