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

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

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

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

j.u = f
f.z = d
f.u = d
f.q = j
d.w = f
d.z = j
assert d.w.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

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

j.u = f
f.z = d
f.u = d
f.q = j
d.w = f
d.z = j
assert d.w.u.w.txt == "f"