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

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

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

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

c.u = k
b.w = k
k.y = b
k.z = b
assert c.u.y.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

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

c.u = k
b.w = k
k.y = b
k.z = b
assert c.u.y.w.txt == "k"