Under construction

Still being built. Things may change

Two-Move Knight

Interview

Time limit1sMemory limit1024 MB

Summary
Given a knight's starting square on a chess board, list every square the knight can reach in exactly two moves.
Level

Easy2 of 10

Topics
Brute force, Implementation
Solved
No attempts yet

Statement

A knight moves in an L-shape: first two squares horizontally or vertically, then one square in the direction perpendicular to the first. The figure below marks every square the knight can reach in one move.

Write a program that finds every square where the knight can be after exactly two moves, starting from a given position on the board.

Input

The first line contains the knight's starting position in standard chess notation: a letter from 'a' to 'h' for the column and a digit from '1' to '8' for the row.

Output

Print each square where the knight can be after two moves, one per line, in the same format as the starting position in the input. The order of the lines does not matter.

Examples1

  1. Example 1

    Input
    a1
    
    Expected output
    c5
    d4
    a5
    c1
    d2
    a1
    e3
    b4
    a3
    e1