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

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

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

class D:
    def __init__(self, txt: str):
        self.t: E = None
        self.txt = txt

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

d = A("d")
m = B("m")
b = C("b")
h = D("h")
l = E("l")
g = D("g")
j = C("j")
n = E("n")
f = A("f")

d.w = h
d.z = b
m.x = b
b.p = d
b.s = g
h.t = n
l.o = m
l.z = b
g.t = l
j.p = d
j.s = g
n.o = m
n.z = b
f.w = g
f.z = j
assert d.w.t.o.x.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.z: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.t: E = None
        self.txt = txt

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

d = A("d")
m = B("m")
b = C("b")
h = D("h")
l = E("l")
g = D("g")
j = C("j")
n = E("n")
f = A("f")

d.w = h
d.z = b
m.x = b
b.p = d
b.s = g
h.t = n
l.o = m
l.z = b
g.t = l
j.p = d
j.s = g
n.o = m
n.z = b
f.w = g
f.z = j
assert d.w.t.o.x.p.w.txt == "h"