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

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

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

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

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

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

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

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

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

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

e.p = h
e.s = h
e.w = h
e.u = f
m.s = k
m.p = d
m.x = d
m.z = b
l.y = b
l.r = b
l.z = m
l.o = f
b.s = m
b.y = d
k.s = d
k.p = d
k.z = h
k.x = m
h.s = k
h.y = m
d.s = k
d.p = k
d.z = b
d.x = m
n.p = h
n.s = h
n.w = h
n.u = l
f.y = b
f.r = h
f.z = m
f.o = l
assert m.x.s.z.y.p.x.p.txt == "d"