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

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

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

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

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

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

m.q = h
h.s = m
a.y = j
a.w = j
a.q = m
a.s = n
l.r = h
l.u = j
l.z = m
n.s = a
n.o = h
n.v = m
j.r = h
j.u = l
j.z = m
assert j.z.q.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

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

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

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

m.q = h
h.s = m
a.y = j
a.w = j
a.q = m
a.s = n
l.r = h
l.u = j
l.z = m
n.s = a
n.o = h
n.v = m
j.r = h
j.u = l
j.z = m
assert j.z.q.s.q.txt == "h"