def findTeleportersD(mz):
    (start, stop) = findTeleporters(mz)
    minx = min((c[0] for c in mz.keys()))
    maxx = max((c[0] for c in mz.keys()))
    miny = min((c[1] for c in mz.keys()))
    maxy = max((c[1] for c in mz.keys()))
    portalLocations = [key for key in mz.keys() if isinstance(mz[key], tuple)]
    for (x, y) in portalLocations:
        mz[(x, y)] = (mz[(x, y)] + (((abs((x - minx)) < 2) or (abs((x - maxx)) < 2) or (abs((y - miny)) < 2) or (abs((y - maxy)) < 2)),))
    return (start, stop)
def findTeleportersD(mz):
    (start, stop) = findTeleporters(mz)
    minx = min((c[0] for c in mz.keys()))
    maxx = max((c[0] for c in mz.keys()))
    miny = min((c[1] for c in mz.keys()))
    maxy = max((c[1] for c in mz.keys()))
    portalLocations = [key for key in mz.keys() if isinstance(mz[key], tuple)]
    for (x, y) in portalLocations:
        mz[(x, y)] = (mz[(x, y)] + (((abs((x - minx)) < 2) or (abs((x - maxx)) < 2) or (abs((y - miny)) < 2) or (abs((y - maxy)) < 2)),))
    return (start, stop)