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

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

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

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

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

d = A("d")
i = B("i")
n = C("n")
c = D("c")
k = E("k")

d.q = i
i.u = k
i.p = c
n.q = i
n.u = c
n.w = k
n.z = k
c.w = n
c.p = i
k.o = d
assert n.u.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

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

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

d = A("d")
i = B("i")
n = C("n")
c = D("c")
k = E("k")

d.q = i
i.u = k
i.p = c
n.q = i
n.u = c
n.w = k
n.z = k
c.w = n
c.p = i
k.o = d
assert n.u.p.u.txt == "k"