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

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

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

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

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

d = A("d")
b = B("b")
m = C("m")
a = D("a")
n = E("n")
e = C("e")
j = B("j")

d.r = j
d.s = m
b.q = d
b.r = d
b.p = m
m.o = e
m.w = b
a.p = e
a.q = d
n.z = e
e.o = m
e.w = b
j.q = d
j.r = d
j.p = m
assert b.p.w.q.s.w.p.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.s: C = None
        self.txt = txt

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

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

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

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

d = A("d")
b = B("b")
m = C("m")
a = D("a")
n = E("n")
e = C("e")
j = B("j")

d.r = j
d.s = m
b.q = d
b.r = d
b.p = m
m.o = e
m.w = b
a.p = e
a.q = d
n.z = e
e.o = m
e.w = b
j.q = d
j.r = d
j.p = m
assert b.p.w.q.s.w.p.o.txt == "e"