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

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

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

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

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

n.v = j
n.o = k
b.s = k
j.p = b
j.z = n
k.r = j
assert b.s.r.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.o: D = None
        self.txt = txt

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

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

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

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

n.v = j
n.o = k
b.s = k
j.p = b
j.z = n
k.r = j
assert b.s.r.p.s.txt == "k"