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

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

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

c = A("c")
b = B("b")
m = C("m")

c.z = b
b.s = c
b.r = m
m.t = b
assert c.z.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

c = A("c")
b = B("b")
m = C("m")

c.z = b
b.s = c
b.r = m
m.t = b
assert c.z.s.z.txt == "b"