def colorMap(mz, start, stop):
    d = collections.deque()
    d.append(start)
    v = dict()
    v[start] = 0
    while (len(d) > 0):
        cur = d.popleft()
        (x, y) = cur
        for (dx, dy) in ((0, 1), (1, 0), ((- 1), 0), (0, (- 1))):
            (nx, ny) = ((x + dx), (y + dy))
            if ((nx, ny) == stop):
                return (v[(x, y)] - 1)
            if ((nx, ny) not in mz):
                continue
            if isinstance(mz[(nx, ny)], tuple):
                (nx, ny) = mz[(nx, ny)]
            if (mz[(nx, ny)] != '.'):
                continue
            if (((nx, ny) in v) and ((v[(x, y)] + 1) >= v[(nx, ny)])):
                continue
            v[(nx, ny)] = (v[(x, y)] + 1)
            d.append((nx, ny))
def colorMap(mz, start, stop):
    d = collections.deque()
    d.append(start)
    v = dict()
    v[start] = 0
    while (len(d) > 0):
        cur = d.popleft()
        (x, y) = cur
        for (dx, dy) in ((0, 1), (1, 0), ((- 1), 0), (0, (- 1))):
            (nx, ny) = ((x + dx), (y + dy))
            if ((nx, ny) == stop):
                return (v[(x, y)] - 1)
            if ((nx, ny) not in mz):
                continue
            if isinstance(mz[(nx, ny)], tuple):
                (nx, ny) = mz[(nx, ny)]
            if (mz[(nx, ny)] != '.'):
                continue
            if (((nx, ny) in v) and ((v[(x, y)] + 1) >= v[(nx, ny)])):
                continue
            v[(nx, ny)] = (v[(x, y)] + 1)
            d.append((nx, ny))