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

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

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

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

a.u = f
a.q = f
n.r = f
n.s = f
f.u = n
f.s = n
f.z = n
assert n.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.q: C = None
        self.txt = txt

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

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

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

a.u = f
a.q = f
n.r = f
n.s = f
f.u = n
f.s = n
f.z = n
assert n.s.s.s.txt == "f"