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

class B:
    def __init__(self, txt: str):
        self.q: D = None
        self.t: D = None
        self.v: A = None
        self.x: E = None
        self.s: D = None
        self.txt = txt

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

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

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

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

b.p = n
d.q = c
d.t = c
d.s = c
d.v = b
d.x = n
h.o = d
h.w = d
c.x = n
n.r = d
n.z = h
n.y = c
assert h.w.v.p.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: D = None
        self.t: D = None
        self.v: A = None
        self.x: E = None
        self.s: D = None
        self.txt = txt

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

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

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

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

b.p = n
d.q = c
d.t = c
d.s = c
d.v = b
d.x = n
h.o = d
h.w = d
c.x = n
n.r = d
n.z = h
n.y = c
assert h.w.v.p.z.txt == "h"