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

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

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

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

k = A("k")
a = B("a")
g = C("g")
l = D("l")

k.s = g
a.u = g
a.w = k
g.o = a
g.z = a
g.u = a
g.w = k
l.u = g
assert k.s.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

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

k = A("k")
a = B("a")
g = C("g")
l = D("l")

k.s = g
a.u = g
a.w = k
g.o = a
g.z = a
g.u = a
g.w = k
l.u = g
assert k.s.z.w.txt == "k"