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

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

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

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

n = A("n")
c = B("c")
d = C("d")
i = D("i")

n.s = i
n.r = d
n.v = c
c.s = i
c.t = n
d.v = c
i.w = n
i.t = n
assert c.s.w.v.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.r: C = None
        self.v: B = None
        self.txt = txt

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

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

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

n = A("n")
c = B("c")
d = C("d")
i = D("i")

n.s = i
n.r = d
n.v = c
c.s = i
c.t = n
d.v = c
i.w = n
i.t = n
assert c.s.w.v.txt == "c"