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

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

class C:
    def __init__(self, txt: str):
        self.y: A = None
        self.q: E = None
        self.r: D = None
        self.o: E = None
        self.txt = txt

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

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

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

h.r = l
h.t = m
l.x = a
j.y = a
j.q = n
j.r = m
j.o = e
m.y = n
m.z = j
n.u = j
e.u = j
a.r = l
a.t = m
c.r = l
c.t = m
assert m.y.u.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.t: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.y: A = None
        self.q: E = None
        self.r: D = None
        self.o: E = None
        self.txt = txt

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

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

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

h.r = l
h.t = m
l.x = a
j.y = a
j.q = n
j.r = m
j.o = e
m.y = n
m.z = j
n.u = j
e.u = j
a.r = l
a.t = m
c.r = l
c.t = m
assert m.y.u.r.z.txt == "j"