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

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

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

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

h.w = e
h.y = e
h.v = f
f.r = h
e.t = h
e.z = h
assert h.w.z.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.y: C = None
        self.v: B = None
        self.txt = txt

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

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

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

h.w = e
h.y = e
h.v = f
f.r = h
e.t = h
e.z = h
assert h.w.z.y.txt == "e"