Chess attack

You are given pairs of chess pieces with locations; for each pair, you are to output true if the first piece can attack the second, and false otherwise.

Input

A number n1n \geq 1, followed by nn pairs of pieces.

Each piece is specified in the following format: type xx yy. Type is a character: K for king, Q for queen, R for rook, B for bishop, and N for knight. xx and yy are ints such that 0x70 \leq x \leq 7 and 0y70 \leq y \leq 7; they specify the xx and yy coordinates of the piece’s position on the chessboard.

In each pair, the two pieces are guaranteed to be in different positions.

Output

For each pair, output true if the first piece can attack the second, and false otherwise. Refer to Wikipedia (or another internet source) for information on how each of the pieces behave.

Observation

Problem information

Author: Hubie Chen

Generation: 2026-01-25T22:34:01.441Z

© Jutge.org, 2006–2026.
https://jutge.org