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

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

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

a = A("a")
c = B("c")
m = C("m")
d = A("d")

a.z = m
c.v = a
c.u = a
c.w = m
m.u = a
d.z = m
assert c.w.u.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

a = A("a")
c = B("c")
m = C("m")
d = A("d")

a.z = m
c.v = a
c.u = a
c.w = m
m.u = a
d.z = m
assert c.w.u.z.u.txt == "a"