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

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

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

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

d.z = m
f.u = m
m.u = f
assert d.z.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

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

d.z = m
f.u = m
m.u = f
assert d.z.u.u.txt == "m"