QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 512 MB Points totaux : 100

#3780. Defective Chessboard

Statistiques

In chess, the king is the most important piece. In each step, the king can move one square horizontally, vertically, or diagonally, as shown in the figure below.

Given two squares $A(r1, c1)$ and $B(r2, c2)$, your task is to calculate the minimum number of steps a king needs to travel from $A$ to $B$. To make the problem less trivial, we have removed a square $C(r3, c3)$ from the board (it is guaranteed that $A$, $B$, and $C$ are distinct), and the king is not allowed to enter square $C$ while moving from $A$ to $B$. In this problem, rows are numbered 1 to 8 from top to bottom, and columns are numbered 1 to 8 from left to right.

Input

The input contains no more than 10,000 test cases. Each test case contains 6 integers $r1, c1, r2, c2, r3, c3$ ($1 \le r1, c1, r2, c2, r3, c3 \le 8$). It is guaranteed that the three squares $A, B, C$ are distinct.

Output

For each test case, output the test case number and the minimum number of steps.

Examples

Input 1

1 1 8 7 5 6
1 1 3 3 2 2

Output 1

Case 1: 7
Case 2: 3

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.