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

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

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

class D:
    def __init__(self, txt: str):
        self.t: B = None
        self.s: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.s: C = None
        self.u: C = None
        self.r: C = None
        self.y: C = None
        self.txt = txt

i = A("i")
j = B("j")
k = C("k")
e = D("e")
d = E("d")

i.q = k
j.w = i
k.z = e
k.s = i
e.t = j
e.s = j
d.s = k
d.u = k
d.r = k
d.y = k
assert k.z.t.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.t: B = None
        self.s: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.s: C = None
        self.u: C = None
        self.r: C = None
        self.y: C = None
        self.txt = txt

i = A("i")
j = B("j")
k = C("k")
e = D("e")
d = E("d")

i.q = k
j.w = i
k.z = e
k.s = i
e.t = j
e.s = j
d.s = k
d.u = k
d.r = k
d.y = k
assert k.z.t.w.q.txt == "k"