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

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

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

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

k = A("k")
e = B("e")
c = C("c")
l = D("l")
a = D("a")
j = B("j")

k.s = j
k.z = c
e.x = a
c.r = a
l.s = k
a.s = k
j.x = a
assert l.s.s.x.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.z: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.txt = txt

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

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

k = A("k")
e = B("e")
c = C("c")
l = D("l")
a = D("a")
j = B("j")

k.s = j
k.z = c
e.x = a
c.r = a
l.s = k
a.s = k
j.x = a
assert l.s.s.x.s.z.txt == "c"