class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

e = A("e")
k = B("k")
g = A("g")
i = A("i")
f = B("f")

e.o = i
k.z = f
g.o = e
i.o = g
f.z = k
assert k.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

e = A("e")
k = B("k")
g = A("g")
i = A("i")
f = B("f")

e.o = i
k.z = f
g.o = e
i.o = g
f.z = k
assert k.z.z.z.z.z.txt == "f"