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

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

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

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

n = A("n")
k = B("k")
a = C("a")
e = D("e")
i = C("i")

n.q = k
k.w = i
a.x = i
a.w = k
e.p = i
e.z = a
i.x = a
i.w = k
assert k.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

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

n = A("n")
k = B("k")
a = C("a")
e = D("e")
i = C("i")

n.q = k
k.w = i
a.x = i
a.w = k
e.p = i
e.z = a
i.x = a
i.w = k
assert k.w.w.w.w.w.txt == "i"