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

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

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

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

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

h = A("h")
n = B("n")
a = C("a")
j = D("j")
k = E("k")
b = D("b")
c = A("c")

h.q = j
n.x = h
n.y = k
n.o = k
n.s = k
a.q = k
a.p = k
a.w = j
a.r = h
j.o = a
j.q = a
j.p = k
j.x = b
k.w = c
b.o = a
b.q = a
b.p = k
b.x = j
c.q = j
assert c.q.x.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.txt = txt

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

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

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

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

h = A("h")
n = B("n")
a = C("a")
j = D("j")
k = E("k")
b = D("b")
c = A("c")

h.q = j
n.x = h
n.y = k
n.o = k
n.s = k
a.q = k
a.p = k
a.w = j
a.r = h
j.o = a
j.q = a
j.p = k
j.x = b
k.w = c
b.o = a
b.q = a
b.p = k
b.x = j
c.q = j
assert c.q.x.q.r.txt == "h"