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

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

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

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

m = A("m")
c = B("c")
l = C("l")
k = D("k")
d = C("d")

m.u = k
c.z = d
c.u = m
l.w = k
k.s = m
k.o = l
d.w = k
assert c.z.w.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

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

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

m = A("m")
c = B("c")
l = C("l")
k = D("k")
d = C("d")

m.u = k
c.z = d
c.u = m
l.w = k
k.s = m
k.o = l
d.w = k
assert c.z.w.o.w.txt == "k"