def findTeleporters(mz):
    loc = dict()
    for ((x, y), value) in mz.items():
        if (isinstance(value, str) and value.isupper()):
            for (dx, dy) in ((0, 1), (1, 0), ((- 1), 0), (0, (- 1))):
                nxtChar = mz.get(((x + dx), (y + dy)), '')
                if isinstance(nxtChar, tuple):
                    continue
                prevChar = mz.get(((x - dx), (y - dy)), '')
                if (nxtChar.isupper() and (prevChar == '.')):
                    name = (mz[(min(x, (x + dx)), min(y, (y + dy)))] + mz[(max((x + dx), x), max((y + dy), y))])
                    if (name not in loc):
                        loc[name] = list()
                    loc[name].append(((x, y), ((x - dx), (y - dy))))
    for l in loc.values():
        if (len(l) != 2):
            continue
        mz[l[0][0]] = l[1][1]
        mz[l[1][0]] = l[0][1]
    return (loc['AA'][0][0], loc['ZZ'][0][0])
def findTeleporters(mz):
    loc = dict()
    for ((x, y), value) in mz.items():
        if (isinstance(value, str) and value.isupper()):
            for (dx, dy) in ((0, 1), (1, 0), ((- 1), 0), (0, (- 1))):
                nxtChar = mz.get(((x + dx), (y + dy)), )
                if isinstance(nxtChar, tuple):
                    continue
                prevChar = mz.get(((x - dx), (y - dy)), )
                if (nxtChar.isupper() and (prevChar == '.')):
                    name = (mz[(min(x, (x + dx)), min(y, (y + dy)))] + mz[(max((x + dx), x), max((y + dy), y))])
                    if (name not in loc):
                        loc[name] = list()
                    loc[name].append(((x, y), ((x - dx), (y - dy))))
    for l in loc.values():
        if (len(l) != 2):
            continue
        mz[l[0][0]] = l[1][1]
        mz[l[1][0]] = l[0][1]
    return (loc['AA'][0][0], loc['ZZ'][0][0])