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

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

k = A("k")
i = B("i")
e = B("e")
d = A("d")

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

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

k = A("k")
i = B("i")
e = B("e")
d = A("d")

k.o = i
i.t = d
i.z = e
e.t = d
e.z = i
d.o = e
assert i.t.o.t.o.txt == "e"