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

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

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

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

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

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

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

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

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

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

n.v = f
n.s = j
n.w = l
l.x = f
l.r = j
f.v = n
f.p = n
j.z = n
assert l.x.v.w.txt == "l"