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

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

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

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

m = A("m")
d = B("d")
j = C("j")
f = D("f")
k = C("k")

m.r = j
m.u = f
d.s = f
d.o = m
d.u = k
j.z = m
j.u = m
f.s = m
k.z = m
k.u = m
assert m.u.s.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.u: D = None
        self.txt = txt

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

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

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

m = A("m")
d = B("d")
j = C("j")
f = D("f")
k = C("k")

m.r = j
m.u = f
d.s = f
d.o = m
d.u = k
j.z = m
j.u = m
f.s = m
k.z = m
k.u = m
assert m.u.s.r.z.txt == "m"