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

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

n = A("n")
b = B("b")
m = C("m")
k = D("k")
h = A("h")
l = D("l")
e = C("e")
d = C("d")

n.s = k
n.q = h
n.p = e
b.r = m
m.z = n
k.t = e
k.s = b
k.y = h
k.r = m
h.s = l
h.q = n
h.p = e
l.t = d
l.s = b
l.y = n
l.r = e
e.z = n
d.z = h
assert b.r.z.p.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.q: A = None
        self.p: C = None
        self.txt = txt

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

n = A("n")
b = B("b")
m = C("m")
k = D("k")
h = A("h")
l = D("l")
e = C("e")
d = C("d")

n.s = k
n.q = h
n.p = e
b.r = m
m.z = n
k.t = e
k.s = b
k.y = h
k.r = m
h.s = l
h.q = n
h.p = e
l.t = d
l.s = b
l.y = n
l.r = e
e.z = n
d.z = h
assert b.r.z.p.txt == "e"