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

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

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

l = A("l")
f = B("f")
j = C("j")
c = C("c")
m = B("m")
k = A("k")

l.z = j
l.p = j
l.v = j
f.w = m
f.z = m
f.u = m
j.u = l
j.y = m
c.u = l
c.y = m
m.w = f
m.z = f
m.u = f
k.z = c
k.p = c
k.v = c
assert m.w.w.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.p: C = None
        self.v: C = None
        self.txt = txt

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

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

l = A("l")
f = B("f")
j = C("j")
c = C("c")
m = B("m")
k = A("k")

l.z = j
l.p = j
l.v = j
f.w = m
f.z = m
f.u = m
j.u = l
j.y = m
c.u = l
c.y = m
m.w = f
m.z = f
m.u = f
k.z = c
k.p = c
k.v = c
assert m.w.w.w.z.txt == "m"