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

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

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

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

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

k.v = j
k.t = n
k.p = l
n.w = j
l.w = n
l.p = k
j.s = l
assert k.t.w.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.t: B = None
        self.p: C = None
        self.txt = txt

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

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

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

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

k.v = j
k.t = n
k.p = l
n.w = j
l.w = n
l.p = k
j.s = l
assert k.t.w.s.p.txt == "k"