#C8923. Reachability on a Grid

    ID: 52959 Type: Default 1000ms 256MiB

Reachability on a Grid

Reachability on a Grid

You are given an N x N grid and an animal that can move in any diagonal or straight direction. The animal starts at position (X_start, Y_start) and must reach the destination (X_dest, Y_dest) within K moves. In each move, the animal can traverse any number of cells in one of the eight possible directions, but it is optimal to move diagonally when possible. The minimum number of moves needed to reach the destination is given by \( \max(|X_dest - X_start|, |Y_dest - Y_start|) \). If this minimum number of moves is less than or equal to K, then the destination is reachable; otherwise, it is unreachable.

Your task is to determine for each test case whether the destination can be reached within the allowed number of moves.

inputFormat

The first line contains an integer T, the number of test cases. Each of the next T lines contains 6 space-separated integers: N, X_start, Y_start, X_dest, Y_dest, and K, representing the grid size, the starting coordinates, the destination coordinates, and the allowed moves respectively.

outputFormat

For each test case, output a single line containing either reachable if the destination can be reached within K moves or unreachable otherwise.

## sample
3
5 1 1 3 3 2
5 1 1 5 5 4
5 1 1 5 5 3
reachable

reachable unreachable

</p>