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

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

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

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

m = A("m")
i = B("i")
a = C("a")
c = D("c")

m.w = c
i.y = m
a.s = m
a.v = m
a.t = c
a.w = c
c.x = m
assert a.s.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

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

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

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

m = A("m")
i = B("i")
a = C("a")
c = D("c")

m.w = c
i.y = m
a.s = m
a.v = m
a.t = c
a.w = c
c.x = m
assert a.s.w.x.txt == "m"