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

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

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

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

k = A("k")
l = B("l")
i = C("i")
m = D("m")

k.z = l
k.p = l
k.t = i
k.w = i
l.o = i
i.z = m
m.o = i
m.v = l
m.p = k
assert k.t.z.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.t: C = None
        self.p: B = None
        self.w: C = None
        self.txt = txt

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

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

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

k = A("k")
l = B("l")
i = C("i")
m = D("m")

k.z = l
k.p = l
k.t = i
k.w = i
l.o = i
i.z = m
m.o = i
m.v = l
m.p = k
assert k.t.z.p.p.txt == "l"