/************************************************
Grundlegende Algorithmen mit Java,
http://algorithmen-und-problemloesungen.de/
Copyright @2007-2009 by Doina Logofatu
************************************************/

import java.io.*;
import java.util.*;

public class P09Knight {
  private static final String FileInputName = "springer.in";
  private static final String FileOutputName = "springer.out";

  private int pred[];
  private int table[][];

  P09Knight(int szTable) {
    this.table = new int[szTable][szTable];
    for (int[] tLine : this.table) {
      Arrays.fill(tLine, Integer.MAX_VALUE);
    }
    this.pred = new int[szTable * szTable];
  }

  private boolean onTheTable(int x, int y) {
    int szTable = this.table.length;
    return x >= 0 && x < szTable && y >= 0 && y < szTable;
  }

  private static class Position {
    int row;
    int column;

    Position(int row, int column) {
      this.row = row;
      this.column = column;
    }
  }

  void doMove(int x, int y, int c) {
    ArrayList<Position> v = new ArrayList<Position>();
    int szTable = this.table.length;
    for (int i = -2; i < 3; i++)
      for (int j = -2; j < 3; j++)
        if (2 == Math.abs(i * j)) {
          int xNew = x + i;
          int yNew = y + j;
          if (onTheTable(xNew, yNew) && this.table[xNew][yNew] > c) {
            this.pred[xNew * szTable + yNew] = x * szTable + y;
            this.table[xNew][yNew] = c;
            v.add(new Position(xNew, yNew));
          }
        }
    Position p;
    while (v.size() > 0) {
      int lastIdx = v.size() - 1;
      p = v.get(lastIdx);
      doMove(p.row, p.column, c + 1);
      v.remove(lastIdx);
    }
  }

  private void recoverWay(PrintStream out, int k, int c) {
    if (c != 0) {
      recoverWay(out, pred[k], c - 1);
      int szTable = this.table.length;
      out.printf("(%d, %d)", k / szTable + 1, k % szTable + 1);
    }
  }

  void writeResult(PrintStream out, int l2, int c2) {
    if (this.table[l2][c2] == Integer.MAX_VALUE) {
      out.print("keine Loesung");
      return;
    }
    out.print("Laenge kuerzester Weg: ");
    out.println(this.table[l2][c2]);
    this.recoverWay(out, l2 * this.table.length + c2, this.table[l2][c2] + 1);
  }

  public static void main(String[] args) throws IOException {
    Scanner scanner = null;
    PrintStream out = null;
    try {
      scanner = new Scanner(new File(FileInputName));
      out = new PrintStream(new File(FileOutputName));

      int szTable = scanner.nextInt();

      int l1 = scanner.nextInt();
      int c1 = scanner.nextInt();
      int l2 = scanner.nextInt();
      int c2 = scanner.nextInt();

      l1--;
      l2--;
      c1--;
      c2--;
      P09Knight p = new P09Knight(szTable);
      p.doMove(l1, c1, 1);
      p.writeResult(out, l2, c2);

    } finally {
      if (scanner != null) {
        scanner.close();
      }
      if (out != null) {
        out.close();
      }
    }
  }
}

