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

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

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

class D:
    def __init__(self, txt: str):
        self.o: E = None
        self.z: B = None
        self.p: C = None
        self.u: B = None
        self.txt = txt

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

k = A("k")
m = B("m")
n = C("n")
d = D("d")
c = E("c")
h = C("h")
a = E("a")

k.q = a
m.o = h
n.u = d
n.w = c
n.q = h
n.o = k
d.o = a
d.z = m
d.u = m
d.p = n
c.u = k
c.r = m
h.u = d
h.w = c
h.q = n
h.o = k
a.u = k
a.r = m
assert k.q.r.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.o: E = None
        self.z: B = None
        self.p: C = None
        self.u: B = None
        self.txt = txt

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

k = A("k")
m = B("m")
n = C("n")
d = D("d")
c = E("c")
h = C("h")
a = E("a")

k.q = a
m.o = h
n.u = d
n.w = c
n.q = h
n.o = k
d.o = a
d.z = m
d.u = m
d.p = n
c.u = k
c.r = m
h.u = d
h.w = c
h.q = n
h.o = k
a.u = k
a.r = m
assert k.q.r.o.txt == "h"