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

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

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

j = A("j")
b = B("b")
k = C("k")

j.u = b
b.z = j
k.p = b
k.v = b
k.s = b
assert b.z.u.z.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

j = A("j")
b = B("b")
k = C("k")

j.u = b
b.z = j
k.p = b
k.v = b
k.s = b
assert b.z.u.z.txt == "j"