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

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

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

h = A("h")
m = B("m")
e = C("e")

h.y = e
m.v = h
m.z = h
m.x = e
e.z = h
assert h.y.z.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

h = A("h")
m = B("m")
e = C("e")

h.y = e
m.v = h
m.z = h
m.x = e
e.z = h
assert h.y.z.y.txt == "e"