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

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

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

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

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

n.z = k
i.s = j
j.y = k
j.q = i
k.y = j
k.u = i
k.r = i
assert n.z.r.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

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

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

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

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

n.z = k
i.s = j
j.y = k
j.q = i
k.y = j
k.u = i
k.r = i
assert n.z.r.s.txt == "j"