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

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

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

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

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

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

n.q = a
n.z = j
j.p = k
j.q = a
i.p = a
i.x = b
a.q = b
a.s = i
k.x = a
k.t = n
k.r = n
k.s = n
b.x = a
b.t = n
b.r = n
b.s = n
assert b.x.s.p.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.z: B = None
        self.txt = txt

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

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

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

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

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

n.q = a
n.z = j
j.p = k
j.q = a
i.p = a
i.x = b
a.q = b
a.s = i
k.x = a
k.t = n
k.r = n
k.s = n
b.x = a
b.t = n
b.r = n
b.s = n
assert b.x.s.p.q.x.txt == "a"