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

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

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

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

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

h = A("h")
c = B("c")
b = C("b")
e = D("e")
d = E("d")
k = D("k")

h.w = b
h.t = k
c.z = b
b.w = k
b.z = k
e.z = k
e.s = k
e.w = k
e.r = k
e.p = h
d.o = c
d.v = c
d.r = k
d.t = b
d.x = b
k.z = e
k.s = e
k.w = e
k.r = e
k.p = h
assert b.z.p.t.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.t: D = None
        self.txt = txt

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

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

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

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

h = A("h")
c = B("c")
b = C("b")
e = D("e")
d = E("d")
k = D("k")

h.w = b
h.t = k
c.z = b
b.w = k
b.z = k
e.z = k
e.s = k
e.w = k
e.r = k
e.p = h
d.o = c
d.v = c
d.r = k
d.t = b
d.x = b
k.z = e
k.s = e
k.w = e
k.r = e
k.p = h
assert b.z.p.t.p.w.txt == "b"