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

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

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

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

j.y = m
j.z = l
j.w = l
d.x = j
d.q = c
c.r = m
c.z = d
f.y = l
f.z = j
f.w = j
m.y = l
m.z = l
m.w = f
l.y = m
l.z = j
l.w = f
assert f.z.y.z.w.z.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.z: A = None
        self.w: A = None
        self.txt = txt

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

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

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

j.y = m
j.z = l
j.w = l
d.x = j
d.q = c
c.r = m
c.z = d
f.y = l
f.z = j
f.w = j
m.y = l
m.z = l
m.w = f
l.y = m
l.z = j
l.w = f
assert f.z.y.z.w.z.y.txt == "m"