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

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

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

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

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

e.s = b
e.q = b
e.x = g
l.p = d
l.r = b
g.z = n
g.s = l
b.q = m
b.o = l
i.s = b
i.x = g
i.q = a
m.z = g
m.s = l
d.s = a
d.x = m
d.q = b
n.z = g
n.s = l
a.q = g
a.o = l
assert n.s.p.q.o.r.q.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.x: C = None
        self.q: D = None
        self.txt = txt

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

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

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

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

e.s = b
e.q = b
e.x = g
l.p = d
l.r = b
g.z = n
g.s = l
b.q = m
b.o = l
i.s = b
i.x = g
i.q = a
m.z = g
m.s = l
d.s = a
d.x = m
d.q = b
n.z = g
n.s = l
a.q = g
a.o = l
assert n.s.p.q.o.r.q.s.r.txt == "b"