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

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

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

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

c = A("c")
i = B("i")
j = C("j")
d = D("d")
a = D("a")

c.w = i
c.v = d
c.s = a
i.y = a
i.o = a
j.w = c
d.v = i
a.v = i
assert j.w.v.v.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.v: D = None
        self.s: D = None
        self.txt = txt

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

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

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

c = A("c")
i = B("i")
j = C("j")
d = D("d")
a = D("a")

c.w = i
c.v = d
c.s = a
i.y = a
i.o = a
j.w = c
d.v = i
a.v = i
assert j.w.v.v.y.txt == "a"