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

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

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

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

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

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

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

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

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

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

e.o = n
e.r = b
e.v = j
n.s = b
n.r = e
b.w = n
j.p = e
assert b.w.s.w.r.txt == "e"