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

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

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

b = A("b")
h = B("h")
l = C("l")
k = C("k")
e = A("e")

b.z = e
h.o = l
l.t = h
k.t = h
e.z = b
assert h.o.t.o.t.o.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

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

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

b = A("b")
h = B("h")
l = C("l")
k = C("k")
e = A("e")

b.z = e
h.o = l
l.t = h
k.t = h
e.z = b
assert h.o.t.o.t.o.txt == "l"