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

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

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

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

n = A("n")
l = B("l")
k = C("k")
i = D("i")
f = D("f")

n.z = f
l.s = n
k.t = l
i.y = f
i.w = n
f.y = i
f.w = n
assert n.z.y.w.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

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

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

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

n = A("n")
l = B("l")
k = C("k")
i = D("i")
f = D("f")

n.z = f
l.s = n
k.t = l
i.y = f
i.w = n
f.y = i
f.w = n
assert n.z.y.w.z.w.txt == "n"