{"raw_statement":[{"iden":"statement","content":"Our dear Nathan, when a little child, used to like chess a lot, but this was a long time ago. One of these days he was challenged by @luisgust to a chess match and, as he is a guy that likes hard challenges, he accepted it. The problem is that Nathan keeps forgetting the rules of the game, so he asked you to help him determine if a given opponent's piece can be captured in one move.\n\nChess, in MaratonIME, is represented as a matrix of characters. Instead of playing with black and white pieces, they play with uppercase and lowercase letters. Nathan has chosen to play with the lowercase letters.\n\nBesides that, as usual, the positions on the matrix are given in the following coordinates system: Each position is a pair with a character between _a_ and _h_ (inclusive), representing the column, and an integer between _1_ and _8_ (inclusive), representing the row. For exemple, the position _d2_ refers to the fourth column (from left to right) and second row (from bottom to top), and the position _f6_ refers to the sixth column and sixth row. Lowercase letters start on the bottom of the grid, on lines _1_ and _2_.\n\nHere position A is adjacent position B if A shares a vertex with B, that is, if the distance between their rows is at most one and the distance between their columns is at most one. For example, the position _c4_ is adjacent to 8 positions: _b3_, _b4_, _b5_, _c3_, _c5_, _d3_, _d4_ and _d5_.\n\nThey decided to play a simplified version of chess. To help you, they gave you the following manual on how to play it:   \n\nGiven a matrix representing a chess board and an opponent's piece, your program needs to determine whether you can capture it with one of your pieces. It is guaranteed that each player has at most two bishops, two rooks, two knights, eight pawns, one king and one queen.\n\nThe input begins with 8 lines with 8 characters each, representing the chess board. The first line contains the characters on the positions _a8_, _b8_, ... , _h8_. The second line contains the characters on positions _a7_, _b7_, ... , _h7_, and so on. After that follows a line containing the position of the opponent's piece you wish to capture.  \n\nPrint a single line containing the word _Sim_ if it is possible to capture the piece or _Nao_ otherwise.\n\n"},{"iden":"input","content":"The input begins with 8 lines with 8 characters each, representing the chess board. The first line contains the characters on the positions _a8_, _b8_, ... , _h8_. The second line contains the characters on positions _a7_, _b7_, ... , _h7_, and so on. After that follows a line containing the position of the opponent's piece you wish to capture.  "},{"iden":"output","content":"Print a single line containing the word _Sim_ if it is possible to capture the piece or _Nao_ otherwise."},{"iden":"examples","content":"InputTCBRKBCTPPPPPPPP................................pppppppptcbrkbctd8OutputNaoInput..........................R........p............................c5OutputSim"}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ N, Q \\in \\mathbb{Z}^+ $ denote the number of tables and number of events, respectively.  \nLet $ C = (c_1, c_2, \\dots, c_N) \\in \\mathbb{Z}^N $ be the sequence of table capacities, where $ c_i $ is the number of chairs at table $ i $, with $ 1 \\leq i \\leq N $ and $ 1 \\leq c_i \\leq 10^5 $.  \nLet $ S \\subseteq \\{1, 2, \\dots, N\\} $ be the set of currently available (empty) tables. Initially, $ S = \\{1, 2, \\dots, N\\} $.  \n\n**Constraints**  \n1. $ 1 \\leq N, Q \\leq 10^5 $  \n2. For each event:  \n   - If `in X`: $ 1 \\leq X \\leq 10^5 $  \n   - If `out T`: $ 1 \\leq T \\leq N $, and table $ T $ was occupied prior to this event.  \n\n**Objective**  \nFor each `in X` event:  \nFind the smallest-indexed table $ i \\in S $ such that $ c_i \\geq X $.  \nIf no such $ i $ exists, output $ -1 $.  \nIf such an $ i $ exists, assign the group to table $ i $, remove $ i $ from $ S $, and output $ i $.  \n\nFor each `out T` event:  \nAdd table $ T $ back to $ S $.  \n\n**Output**  \nFor each `in X` event, output the assigned table number or $ -1 $.","simple_statement":"You are given N tables in a line, each with a certain number of chairs. Initially, all tables are empty.\n\nYou process Q events:\n\n- \"in X\": A group of X people arrives. Assign them to the smallest-numbered table that has at least X chairs and is empty. If no such table exists, output -1.\n- \"out T\": The group at table T leaves, making table T empty again.\n\nFor each \"in X\" event, output the table number where the group sits.","has_page_source":false}