class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.z: B = None
        self.x: 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.o: A = None
        self.q: B = None
        self.txt = txt

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

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

m.u = f
m.z = f
m.x = f
f.r = d
l.o = m
l.q = f
d.z = m
d.y = f
assert l.o.u.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.z: B = None
        self.x: 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.o: A = None
        self.q: B = None
        self.txt = txt

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

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

m.u = f
m.z = f
m.x = f
f.r = d
l.o = m
l.q = f
d.z = m
d.y = f
assert l.o.u.r.txt == "d"