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

class B:
    def __init__(self, txt: str):
        self.r: D = None
        self.t: C = 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.x: B = None
        self.s: B = None
        self.txt = txt

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

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

class B:
    def __init__(self, txt: str):
        self.r: D = None
        self.t: C = 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.x: B = None
        self.s: B = None
        self.txt = txt

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

i.s = n
i.x = n
n.r = d
n.t = b
b.v = n
d.x = n
d.s = n
assert b.v.t.v.txt == "n"