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

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

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

class D:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

l = A("l")
a = B("a")
m = C("m")
f = D("f")
n = C("n")
e = A("e")
j = D("j")
k = D("k")

l.w = m
a.z = m
m.s = a
f.o = l
n.s = a
e.w = n
j.o = l
k.o = e
assert k.o.w.s.z.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

l = A("l")
a = B("a")
m = C("m")
f = D("f")
n = C("n")
e = A("e")
j = D("j")
k = D("k")

l.w = m
a.z = m
m.s = a
f.o = l
n.s = a
e.w = n
j.o = l
k.o = e
assert k.o.w.s.z.s.z.txt == "m"