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

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

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

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

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

j.v = i
b.s = e
b.v = e
b.r = i
e.s = j
i.y = j
i.s = j
i.t = b
assert i.s.v.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

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

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

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

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

j.v = i
b.s = e
b.v = e
b.r = i
e.s = j
i.y = j
i.s = j
i.t = b
assert i.s.v.y.v.txt == "i"