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

class B:
    def __init__(self, txt: str):
        self.u: D = None
        self.r: C = None
        self.x: E = None
        self.q: E = None
        self.txt = txt

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

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

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

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

d.u = b
k.u = j
k.r = n
k.x = b
k.q = b
n.w = k
n.u = k
n.q = j
n.t = b
j.p = d
j.s = n
b.z = j
assert k.q.z.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: D = None
        self.r: C = None
        self.x: E = None
        self.q: E = None
        self.txt = txt

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

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

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

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

d.u = b
k.u = j
k.r = n
k.x = b
k.q = b
n.w = k
n.u = k
n.q = j
n.t = b
j.p = d
j.s = n
b.z = j
assert k.q.z.p.u.txt == "b"