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

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

m = A("m")
h = B("h")
j = C("j")
a = D("a")
g = B("g")
d = B("d")
f = B("f")
k = C("k")
e = B("e")

m.z = f
m.s = a
h.p = k
j.p = m
a.z = m
a.x = g
g.p = j
d.p = k
f.p = k
k.p = m
e.p = j
assert d.p.p.z.p.p.s.z.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.s: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

m = A("m")
h = B("h")
j = C("j")
a = D("a")
g = B("g")
d = B("d")
f = B("f")
k = C("k")
e = B("e")

m.z = f
m.s = a
h.p = k
j.p = m
a.z = m
a.x = g
g.p = j
d.p = k
f.p = k
k.p = m
e.p = j
assert d.p.p.z.p.p.s.z.s.txt == "a"