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

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

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

class D:
    def __init__(self, txt: str):
        self.o: B = None
        self.v: B = None
        self.x: A = None
        self.r: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

d = A("d")
c = B("c")
m = C("m")
n = D("n")
b = E("b")
l = C("l")

d.p = m
d.q = n
d.w = c
c.w = b
m.z = n
m.r = n
m.s = b
m.x = b
n.o = c
n.v = c
n.x = d
n.r = m
b.w = d
l.z = n
l.r = n
l.s = b
l.x = b
assert b.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.q: D = None
        self.w: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.o: B = None
        self.v: B = None
        self.x: A = None
        self.r: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

d = A("d")
c = B("c")
m = C("m")
n = D("n")
b = E("b")
l = C("l")

d.p = m
d.q = n
d.w = c
c.w = b
m.z = n
m.r = n
m.s = b
m.x = b
n.o = c
n.v = c
n.x = d
n.r = m
b.w = d
l.z = n
l.r = n
l.s = b
l.x = b
assert b.w.w.w.txt == "b"