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

class B:
    def __init__(self, txt: str):
        self.o: C = None
        self.z: A = None
        self.s: D = None
        self.w: D = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

l = A("l")
f = B("f")
a = C("a")
b = D("b")
i = D("i")
k = B("k")

l.w = i
f.o = a
f.z = l
f.s = b
f.w = b
a.z = l
b.t = a
i.t = a
k.o = a
k.z = l
k.s = b
k.w = i
assert b.t.z.w.t.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: C = None
        self.z: A = None
        self.s: D = None
        self.w: D = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

l = A("l")
f = B("f")
a = C("a")
b = D("b")
i = D("i")
k = B("k")

l.w = i
f.o = a
f.z = l
f.s = b
f.w = b
a.z = l
b.t = a
i.t = a
k.o = a
k.z = l
k.s = b
k.w = i
assert b.t.z.w.t.z.w.txt == "i"