As you probably know, chess is a game that is played on a board with 64 squares arranged in an $$$8\times 8$$$ grid. Columns of this board are labeled with letters from a to h, and rows are labeled with digits from 1 to 8. Each square is described by the row and column it belongs to.
The rook is a piece in the game of chess. During its turn, it may move any non-zero number of squares horizontally or vertically. Your task is to find all possible moves for a rook on an empty chessboard.
The first line of input contains single integer $$$t$$$ ($$$1 \le t \le 64$$$) — the number of test cases. The descriptions of test cases follow.
Each test case contains one string of two characters, description of the square where rook is positioned. The first character is a letter from a to h, the label of column, and the second character is a digit from 1 to 8, the label of row.
The same position may occur in more than one test case.
For each test case, output descriptions of all squares where the rook can move, in the same format as in the input.
You can output squares in any order per test case.
1d5
d1 d2 b5 g5 h5 d3 e5 f5 d8 a5 d6 d7 c5 d4
Slavic is preparing a present for a friend's birthday. He has an array $$$a$$$ of $$$n$$$ digits and the present will be the product of all these digits. Because Slavic is a good kid who wants to make the biggest product possible, he wants to add $$$1$$$ to exactly one of his digits.
What is the maximum product Slavic can make?
The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases.
The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 9$$$) — the number of digits.
The second line of each test case contains $$$n$$$ space-separated integers $$$a_i$$$ ($$$0 \leq a_i \leq 9$$$) — the digits in the array.
For each test case, output a single integer — the maximum product Slavic can make, by adding $$$1$$$ to exactly one of his digits.
442 2 1 230 1 254 3 2 3 499 9 9 9 9 9 9 9 9
16 2 432 430467210
On an $$$8 \times 8$$$ grid of dots, a word consisting of lowercase Latin letters is written vertically in one column, from top to bottom. What is it?
The input consists of multiple test cases. The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases.
Each test case consists of $$$8$$$ lines, each containing $$$8$$$ characters. Each character in the grid is either $$$\texttt{.}$$$ (representing a dot) or a lowercase Latin letter ($$$\texttt{a}$$$–$$$\texttt{z}$$$).
The word lies entirely in a single column and is continuous from the beginning to the ending (without gaps). See the sample input for better understanding.
For each test case, output a single line containing the word made up of lowercase Latin letters ($$$\texttt{a}$$$–$$$\texttt{z}$$$) that is written vertically in one column from top to bottom.
5...................................i.....................................l.......o.......s.......t....................................................................t.......h.......e................................................g.......a.......m.......ea.......a.......a.......a.......a.......a.......a.......a.......
i lost the game aaaaaaaa
Recently, Tema and Vika celebrated Family Day. Their friend Arina gave them a carpet, which can be represented as an $$$n \cdot m$$$ table of lowercase Latin letters.
Vika hasn't seen the gift yet, but Tema knows what kind of carpets she likes. Vika will like the carpet if she can read her name on. She reads column by column from left to right and chooses one or zero letters from current column.
Formally, the girl will like the carpet if it is possible to select four distinct columns in order from left to right such that the first column contains "v", the second one contains "i", the third one contains "k", and the fourth one contains "a".
Help Tema understand in advance whether Vika will like Arina's gift.
Each test consists of multiple test cases. The first line of input contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then follows the description of the test cases.
The first line of each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \le n, m \le 20$$$) — the sizes of the carpet.
The next $$$n$$$ lines contain $$$m$$$ lowercase Latin letters each, describing the given carpet.
For each set of input data, output "YES" if Vika will like the carpet, otherwise output "NO".
You can output each letter in any case (lowercase or uppercase). For example, the strings "yEs", "yes", "Yes", and "YES" will be accepted as a positive answer.
51 4vika3 3badcarpet4 4vvvviiiikkkkaaaa4 4vkakiiaiavvkviaa4 7vbickdavbickdavbickdavbickda
YES NO YES NO YES
In the first sample, Vika can read her name from left to right.
In the second sample, Vika cannot read the character "v", so she will not like the carpet.
Vanya and Vova are playing a game. Players are given an integer $$$n$$$. On their turn, the player can add $$$1$$$ to the current integer or subtract $$$1$$$. The players take turns; Vanya starts. If after Vanya's move the integer is divisible by $$$3$$$, then he wins. If $$$10$$$ moves have passed and Vanya has not won, then Vova wins.
Write a program that, based on the integer $$$n$$$, determines who will win if both players play optimally.
The first line contains the integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases.
The single line of each test case contains the integer $$$n$$$ ($$$1 \leq n \leq 1000$$$).
For each test case, print "First" without quotes if Vanya wins, and "Second" without quotes if Vova wins.
61351009991000
First Second First First Second First
You are given a four-digit pin code consisting of digits from $$$0$$$ to $$$9$$$ that needs to be entered. Initially, the cursor points to the digit $$$1$$$. In one second, you can perform exactly one of the following two actions:
The image above shows the device you are using to enter the pin code. For example, for the digit $$$5$$$, the adjacent digits are $$$4$$$ and $$$6$$$, and for the digit $$$0$$$, there is only one adjacent digit, $$$9$$$.
Determine the minimum number of seconds required to enter the given four-digit pin code.
Each test consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) - the number of the test cases. This is followed by their description.
The single line of each test case describes the pin code as a string of length $$$4$$$, consisting of digits from $$$0$$$ to $$$9$$$.
For each test case, output the minimum number of seconds required to enter the given pin code.
101111123610101920927300007492854302948361
4 9 31 27 28 13 25 16 33 24
In the first test case, the cursor needs to be pressed $$$4$$$ times.
In the second test case, it can be done in $$$9$$$ seconds as follows: