from collections import deque

class Node() :
    def __init__(self, x, y, links):
        self.x = x
        self.y = y
        self.links = links

def print_maze(maze) :
    xmax = 0
    ymax = 0
    for c in maze :
        if c.x > xmax :
            xmax = c.x
        if c.y > ymax :
            ymax = c.y
    width  = xmax * 2 + 3
    height = ymax * 2 + 3
    walls = [ [ 1 for x in range(0, width) ] for y in range(0, height) ]
    for c in maze :
        walls[c.y * 2 + 1][c.x * 2 + 1] = 0
        for l in c.links :
            c2 = maze[l]
            walls[c.y + c2.y + 1][c.x + c2.x + 1] = 0
    for l in walls :
        s = ""
        for w in l :
            if w == 0 :
                s = s + " "
            else :
                s = s + "#"
        print s

def find_path(maze, entry, exit) :
    return "not found"

example_maze = [
    Node(0, 0, [1]),
    Node(1, 0, [0, 6]),
    Node(2, 0, [7]),
    Node(3, 0, [4]),
    Node(4, 0, [3, 9]),
    Node(0, 1, [6, 10]),
    Node(1, 1, [1, 5]),
    Node(2, 1, [2, 8]),
    Node(3, 1, [7, 9, 13]),
    Node(4, 1, [8, 4, 14]),
    Node(0, 2, [5, 11]),
    Node(1, 2, [10, 12]),
    Node(2, 2, [11, 13]),
    Node(3, 2, [8, 12]),
    Node(4, 2, [9]),
]

print_maze(example_maze)

print find_path(example_maze, 0, 14)
