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

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

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

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

class E:
    def __init__(self, txt: str):
        self.p: C = None
        self.u: D = None
        self.y: A = None
        self.s: A = None
        self.q: B = None
        self.txt = txt

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

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.p: C = None
        self.u: D = None
        self.y: A = None
        self.s: A = None
        self.q: B = None
        self.txt = txt

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

d.z = c
m.z = d
m.o = b
h.p = c
h.t = c
h.x = f
h.q = b
h.r = b
c.p = m
c.v = b
c.q = h
b.p = h
b.u = c
b.y = d
b.s = d
b.q = m
f.z = c
assert f.z.q.x.z.p.o.txt == "b"