Bytean chess is one of the most peculiar variants of chess in the world. Playing each match is a major difficulty, because the game is played on an infinite chessboard. The basic ability learnt by young enthusiasts of Bytean chess is considering all possible situations on a chessboard after millions of moves. To perform this, they need to know whether a given chess piece can get from one given square to another one.
The most powerful chess piece in Bytean chess is a
-knight.
Its moves resemble the moves of a knight in traditional chess.
Each of its moves consists of: either moving
squares vertically
and afterwards
squares horizontally, or moving
squares vertically and afterwards
squares horizontally.
The knight from traditional chess can therefore be thought of as
-knight or
-knight.
The task is to verify, for two given squares of the chessboard, if a
-knight can get
from the first square to the second one (the number of necessary moves is not important).
The first line of the standard input contains one integer
(
) denoting the number of test cases.
Each of the following
lines contains a description of a single test case
in the form of six integers
,
,
,
,
,
(
,
,
)
separated by single spaces.
and
describe the possible moves of the knight.
The knight starts its movement in square
.
W would like to check if it can get to square
.
For each test case exactly one line should be written to the standard output.
It should contain a word TAK (meaning YES) or NIE (meaning NO)
depending on whether a
-knight starting from square
can get to square
.
For the input data:
3 2 1 0 0 3 3 1 1 1 1 1 2 1 0 2 3 4 6
the correct result is:
TAK NIE TAK
Task author: Jakub Onufry Wojtaszczyk.
W razie problemów technicznych ze Szkopułem, prosimy o kontakt mailowy pod adresem szkopul@fri.edu.pl.
Jeśli chciałbyś porozmawiać o zadaniach, rozwiązaniach lub problemach technicznych, odwiedź nasze serwery na Discordzie. Są one moderowane przez społeczność, ale członkowie zespołu wsparcia również aktywnie się tam udzielają.