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

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

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

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

e = A("e")
g = B("g")
d = C("d")
n = D("n")
m = C("m")
l = D("l")

e.r = l
e.s = l
e.z = g
g.p = n
g.u = d
d.z = m
d.t = g
d.s = g
n.z = d
n.w = m
m.z = d
m.t = g
m.s = g
l.z = d
l.w = m
assert d.z.z.z.z.z.s.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.s: D = None
        self.z: B = None
        self.txt = txt

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

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

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

e = A("e")
g = B("g")
d = C("d")
n = D("n")
m = C("m")
l = D("l")

e.r = l
e.s = l
e.z = g
g.p = n
g.u = d
d.z = m
d.t = g
d.s = g
n.z = d
n.w = m
m.z = d
m.t = g
m.s = g
l.z = d
l.w = m
assert d.z.z.z.z.z.s.txt == "g"