Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/boolean-tosiqli-ruh-yurishi

Rook move with an obstacle

Medium 1000 ms 64 MB 42%
Share

Three different squares are given on a chessboard: a rook stands on square $(x_{1}; y_{1})$, and another piece stands on square $(x_{3}; y_{3})$. A square is given as $(x; y)$: $x$ is the column number (from left to right), $y$ is the row number (from bottom to top). A rook moves any distance along a column or a row but cannot jump over another piece. Check whether the statement is true: “the rook can move to square $(x_{2}; y_{2})$ in one move”.

An obstacle square in the rook's path on a chessboard

Input

One line with six positive integers: $x_{1}$, $y_{1}$, $x_{2}$, $y_{2}$, $x_{3}$ and $y_{3}$.

Output

One integer: $1$ if the statement is true, otherwise $0$.

Note

$1 \le x_{1}, y_{1}, x_{2}, y_{2}, x_{3}, y_{3} \le 8$
All three squares are different.

Examples

Input #1
1 1 1 6 1 4
Output #1
0
Input #2
1 1 1 6 3 3
Output #2
1

Sign in to submit a solution

Signing up is free and takes a minute.