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

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

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

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

d.z = h
d.r = m
d.t = m
m.u = d
m.s = d
h.z = m
h.v = m
h.r = m
assert d.z.r.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.r: B = None
        self.t: B = None
        self.txt = txt

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

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

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

d.z = h
d.r = m
d.t = m
m.u = d
m.s = d
h.z = m
h.v = m
h.r = m
assert d.z.r.s.txt == "d"