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

class B:
    def __init__(self, txt: str):
        self.t: A = 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.w: C = None
        self.txt = txt

c = A("c")
a = B("a")
j = C("j")
n = D("n")
k = D("k")
h = D("h")
e = A("e")
m = C("m")

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

class B:
    def __init__(self, txt: str):
        self.t: A = 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.w: C = None
        self.txt = txt

c = A("c")
a = B("a")
j = C("j")
n = D("n")
k = D("k")
h = D("h")
e = A("e")
m = C("m")

c.s = e
c.z = m
a.t = e
j.z = e
n.w = m
k.w = j
h.w = j
e.s = c
e.z = j
m.z = e
assert j.z.z.z.z.z.s.s.txt == "e"