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

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

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

e = A("e")
i = B("i")
m = C("m")
h = B("h")
g = A("g")
b = C("b")
c = B("c")

e.z = b
i.y = g
m.z = e
h.y = e
g.z = m
b.z = g
c.y = e
assert b.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

e = A("e")
i = B("i")
m = C("m")
h = B("h")
g = A("g")
b = C("b")
c = B("c")

e.z = b
i.y = g
m.z = e
h.y = e
g.z = m
b.z = g
c.y = e
assert b.z.z.z.z.txt == "b"