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

class B:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

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

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

m = A("m")
c = B("c")
l = C("l")
h = D("h")
j = E("j")
a = D("a")
b = C("b")

m.p = c
m.q = c
m.y = b
m.w = j
c.u = a
l.t = c
l.s = m
h.o = a
h.p = a
h.v = m
h.u = b
j.v = b
j.u = h
j.q = h
a.o = h
a.p = h
a.v = m
a.u = b
b.t = c
b.s = m
assert h.v.p.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.q: B = None
        self.y: C = None
        self.w: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

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

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

m = A("m")
c = B("c")
l = C("l")
h = D("h")
j = E("j")
a = D("a")
b = C("b")

m.p = c
m.q = c
m.y = b
m.w = j
c.u = a
l.t = c
l.s = m
h.o = a
h.p = a
h.v = m
h.u = b
j.v = b
j.u = h
j.q = h
a.o = h
a.p = h
a.v = m
a.u = b
b.t = c
b.s = m
assert h.v.p.u.o.txt == "h"