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

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

class C:
    def __init__(self, txt: str):
        self.t: D = None
        self.p: D = None
        self.txt = txt

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

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

l.u = d
d.r = m
c.t = m
c.p = m
m.z = l
assert c.t.z.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.t: D = None
        self.p: D = None
        self.txt = txt

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

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

l.u = d
d.r = m
c.t = m
c.p = m
m.z = l
assert c.t.z.u.r.txt == "m"