Under construction

Still being built. Things may change

Unskippable subway game

Interview

Time limit1sMemory limit1024 MB

Summary
Given N stations where some are transfer stops, two players take turns advancing a subway model, and whoever places it at station N wins. Find the winner.
Level

Medium5 of 10

Topics
Game theory, Array, Implementation
Solved
No attempts yet

Problem

Sehun and Mina want to play a game using a subway map and a subway model.

The map shows only one line, and NN stations are connected in a row along it. The stations are numbered from 11 to NN in order. For every integer ii with 1≤i<N1 \le i < N, the station after station ii is station i+1i+1. So the station after 11 is 22, the station after 22 is 33, ⋯\cdots, and the station after N−1N-1 is NN.

Every station except station 11 and station NN is either a transfer station or a regular station. The starting station 11 and the terminal station NN are always regular stations.

The rules of the game are as follows.

  1. Place the subway model at station 11.
  2. Sehun goes first, and the two players take turns.
  3. On each turn, a player moves the model to the next station one or more times, as many times as they like, and then passes the turn. However, if the model reaches a transfer station after a move, it cannot move any further. The turn passes to the opponent the moment the model arrives at a transfer station.
  4. The player who places the model at station NN during their own turn wins.

Both players always make the best possible choice to win. Given the information about the subway line, write a program that finds the winner.

Input

The first line contains the number of stations NN. (2≤N≤500 000)(2 \le N \le 500\,000)

The second line contains NN integers A1,⋯ ,ANA_1, \cdots, A_N separated by spaces, which describe each station. If station ii is a regular station, then Ai=0A_i = 0. If it is a transfer station, then Ai=1A_i = 1. A1A_1 and ANA_N are always 00.

Output

On the first line, print mnx if Sehun wins, or alsdkffhgk if Mina wins.

Examples2

  1. Example 1

    Input
    7
    0 1 0 0 1 0 0
    
    Expected output
    alsdkffhgk
    
  2. Example 2

    Input
    5
    0 0 0 1 0
    
    Expected output
    mnx