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

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

class C:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

d.u = i
d.t = i
d.p = m
d.r = m
m.s = b
m.x = i
i.u = m
b.z = d
b.w = i
b.v = m
assert d.r.s.w.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.t: C = None
        self.p: B = None
        self.r: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

d.u = i
d.t = i
d.p = m
d.r = m
m.s = b
m.x = i
i.u = m
b.z = d
b.w = i
b.v = m
assert d.r.s.w.u.txt == "m"