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

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.z: A = None
        self.txt = txt

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.z: A = None
        self.txt = txt

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

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

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

d.v = m
d.t = m
a.p = c
a.z = d
c.x = d
c.s = m
m.w = a
assert d.t.w.p.txt == "c"