class A:
    def __init__(self, txt: str):
        self.z: 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.x: A = None
        self.u: A = None
        self.s: B = None
        self.txt = txt

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

f.z = d
d.r = f
a.x = f
a.u = f
a.s = d
assert a.x.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.z: 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.x: A = None
        self.u: A = None
        self.s: B = None
        self.txt = txt

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

f.z = d
d.r = f
a.x = f
a.u = f
a.s = d
assert a.x.z.r.txt == "f"